JS: Symbol.prototype
(new in ECMAScript 2015)
What is Symbol.prototype
Symbol.prototype is the value of the property key "prototype" of the function Symbol. 〔see Symbol Object〕
console.assert(Object.hasOwn(Symbol, "prototype"));
Type
Type of Symbol.prototype is Object
.
console.assert(typeof Symbol.prototype === "object");
Parent
Parent of Symbol.prototype is Object.prototype
.
console.assert(Reflect.getPrototypeOf(Symbol.prototype) === Object.prototype);
Purpose
Symbol.prototype is the parent of all symbol objects.
console.assert(Reflect.getPrototypeOf(Object(Symbol())) === Symbol.prototype); // Object(xx) converts symbol primitive xx to a symbol object
Properties
work in progressSymbol.prototype.constructor
Symbol.prototype.description
Return the description of the symbol.
Symbol.prototype.toString( )
return a string of the form:
"Symbol(description)"
console.assert(Symbol("xyz").toString() === "Symbol(xyz)");