JavaScripture
Contribute via GitHub Feedback

JavaScript Symbol : Object

Symbols are an alternate to using Strings as the keys for properties. Symbols allow hiding properties on Objects since you can only access the values if you have the same instance of the Symbol. You access a property with a Symbol key using object[symbol].

Symbol([description : String]) : Symbol

Creates a new Symbol with an optional description.

Example:

Run

Results:

 

Symbol Properties

hasInstance : Symbol

isConcatSpreadable : Symbol

isRegExp : Symbol

iterator : Symbol

The Symbol that retrieves a function that returns an iterator for the Object.

Example:

Run

Results:

 

toPrimitive : Symbol

toStringTag : Symbol

unscopables : Symbol