JS: Symbol.prototype

By Xah Lee. Date: . Last updated: .

New in ES2015.

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

[see JS: Symbol Object]

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

Type of Symbol.prototype is object.

[see JS: What's Object?]

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

Parent of Symbol.prototype is Object.prototype.

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

Symbol.prototype is the parent of all symbol objects.

let sym = Symbol();
console.log ( Object.getPrototypeOf ( sym ) === Symbol.prototype ); // true

[see JS: Prototype and Inheritance]

Properties

  1. Symbol.prototype.constructor
  2. Symbol.prototype.toString ( )
  3. Symbol.prototype.valueOf ( )
  4. Symbol.prototype [ Symbol.toPrimitive ] ( hint )
  5. Symbol.prototype [ Symbol.toStringTag ]

2017-02-10 following is work in progress.













Symbol.prototype.constructor

Symbol.prototype.constructor is a value property.

The value is the object Symbol.

console.log ( Symbol.prototype.constructor === Symbol ); // true

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

Symbol.prototype.toString ( )

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

Reference

ECMAScript® 2016 Language Specification#sec-properties-of-the-symbol-prototype-object

Symbol Topic

  1. JS: Symbol Tutorial
  2. JS: Symbol Object
  3. JS: Symbol.prototype
Liket it? Put $1 at patreon.

Or, Buy JavaScript in Depth