JavaScripture
Contribute via GitHub Feedback

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:

 

Instance Properties

description : String

Returns the description passed to the Symbol during construction.

Example:

Run

Results:

 

Symbol Properties

asyncIterator : Symbol
hasInstance : Symbol
isConcatSpreadable : Symbol
iterator : Symbol

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

Example:

Run

Results:

 

match : Symbol
matchAll : Symbol
replace : Symbol
search : Symbol
species : Symbol
split : Symbol
toPrimitive : Symbol
toStringTag : Symbol
unscopables : Symbol

Symbol Methods

for(key : String) : Symbol
keyFor(key : String) : Symbol