JS: Symbol.prototype
New in JS2015.
What is Symbol.prototype
Symbol.prototype
is the value of the property key "prototype"
of the function Symbol
. 〔see Symbol Object〕
Symbol.hasOwnProperty("prototype")
Type
Type of Symbol.prototype
is Object
.
typeof Symbol.prototype === "object"
Parent
Parent of Symbol.prototype
is Object.prototype
.
// parent of Symbol.prototype console.log(Reflect.getPrototypeOf(Symbol.prototype) === Object.prototype);
Purpose
Symbol.prototype
is the parent of all symbol objects.
let ss = Symbol(); console.log( Reflect.getPrototypeOf(Object(ss)) === Symbol.prototype, ); // Object(ss) converts symbol primitive ss to a symbol object
Properties
constructor
description
toString
valueOf
[ Symbol.toPrimitive ]
[ Symbol.toStringTag ]
2017-02-10 following is work in progress.
Symbol.prototype.constructor
Symbol.prototype.constructor
-
The value is the object
Symbol
.
Symbol.prototype.constructor === Symbol
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)");