JS: Symbol.prototype

By Xah Lee. Date: . Last updated: .

(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

〔see Prototype and Inheritance

Properties

work in progress

Symbol.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)");

Symbol.prototype.valueOf ( )

Symbol.prototype [ Symbol.toPrimitive ] ( hint )

Symbol.prototype [ Symbol.toStringTag ]

JavaScript. Symbol