JavaScript: Symbol.prototype

By Xah Lee. Date: . Last updated: .

New in JS2015.

Symbol.prototype is the value of the property key "prototype" of the function Symbol.

[see Symbol Object]

console.log( Symbol.hasOwnProperty ( "prototype" ) ); // true

Type

Type of Symbol.prototype is Object .

console.log( typeof Symbol.prototype === "object" ); // true

console.log( Object.prototype.toString.call( Symbol.prototype ) === "[object Symbol]" ) // true

Parent

Parent of Symbol.prototype is Object.prototype .

// parent of Symbol.prototype
console.log( Reflect.getPrototypeOf ( Symbol.prototype ) === Object.prototype ); // true

Purpose

Symbol.prototype is the parent of all symbol objects.

let ss = Symbol();

console.log( 
Reflect.getPrototypeOf ( Object(ss) ) === Symbol.prototype
); // true

// Object(ss) converts symbol primitive ss to a symbol object

[see Prototype and Inheritance]

Properties


2017-02-10 following is work in progress.













Symbol.prototype.constructor

Symbol.prototype.constructor
The value is the object Symbol.
console.log( Symbol.prototype.constructor === Symbol ); // true

ECMAScript® 2016 Language Specification#sec-symbol.prototype.constructor

Symbol.prototype.description

Return the description of the symbol.

Symbol.prototype.toString( )

return a string of the form:

"Symbol(description)"

const x = Symbol("xyz");
console.log( x.toString() === "Symbol(xyz)" ); // true

ECMAScript® 2016 Language Specification#sec-symbol.prototype.tostring

Symbol.prototype.valueOf ( )

ECMAScript® 2016 Language Specification#sec-symbol.prototype.valueof

Symbol.prototype [ Symbol.toPrimitive ] ( hint )

ECMAScript® 2016 Language Specification#sec-symbol.prototype-@@toprimitive

Symbol.prototype [ Symbol.toStringTag ]

ECMAScript® 2016 Language Specification#sec-symbol.prototype-@@tostringtag

JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS Obj Ref

Symbol

prototype