Source code
Revision control
Copy as Markdown
Other Tools
/* Any copyright is dedicated to the Public Domain.
var symbols = [
Symbol(),
Symbol("ok"),
Symbol.for("dummies"),
Symbol.iterator
];
for (var sym of symbols) {
assertEq(sym.valueOf(), sym);
assertEq(Object(sym).valueOf(), sym);
}
// Any other value throws.
var nonsymbols = [undefined, null, NaN, {}, Symbol.prototype];
for (var nonsym of nonsymbols)
assertThrowsInstanceOf(() => Symbol.prototype.valueOf.call(nonsym), TypeError);
if (typeof reportCompare === "function")
reportCompare(0, 0);