Symbol
Symbol
lives in the global scope
const actual = someNamespace.Symbol;
assert.equal(actual, Symbol);
every Symbol()
is unique
const sym1 = Symbol();
const sym2 = sym1;
assert.notEqual(sym1, sym2);
every Symbol()
is unique, also with the same parameter
var sym1 = Symbol('foo');
var sym1 = Symbol('foo');
assert.notEqual(sym1, sym2);
typeof Symbol()
returns "symbol"
const theType = typeof Symbol;
assert.equal(theType, 'symbol');
new Symbol()
throws an exception, to prevent creation of Symbol wrapper objects
function fn() {
Symbol();
}
assert.throws(fn);