Class Symbol
Symbol is a primitive data type that can serve as object properties.
Symbol instance can be created explicitly or via a global registry, see for(String) .
API Version:
Available from version 21.2.
Constant Summary
Constructor Summary
Method Summary
Method Description static for (String ) Obtains a symbol from the global registry. static keyFor (Symbol ) Returns the key within the global symbol registry under which the given symbol is stored.
Methods inherited from class Object
assign , create , create , defineProperties , defineProperty , entries , freeze , fromEntries , getOwnPropertyDescriptor , getOwnPropertyNames , getOwnPropertySymbols , getPrototypeOf , hasOwnProperty , is , isExtensible , isFrozen , isPrototypeOf , isSealed , keys , preventExtensions , propertyIsEnumerable , seal , setPrototypeOf , toLocaleString , toString , valueOf , values
Constant Details
hasInstance
hasInstance: Symbol
The symbol used by instanceof.
isConcatSpreadable
isConcatSpreadable: Symbol
The symbol used by Array.concat(Object...) .
iterator
iterator: Symbol
The symbol used by for...of.
match
match: Symbol
The symbol used by String.match(RegExp) .
replace
replace: Symbol
The symbol used by String.replace().
search
search: Symbol
The symbol used by String.search(RegExp) .
species
species: Symbol
The symbol used to create derived objects.
split
split: Symbol
The symbol used by String.split().
toPrimitive
toPrimitive: Symbol
The symbol used to convert an object to a primitive value.
toStringTag
toStringTag: Symbol
The symbol used by Object.toString() .
unscopables
unscopables: Symbol
The symbol used by with.
Constructor Details
Symbol()
Symbol()
Creates a new symbol. Note that it must be called without new.
Symbols created via this method are always distinct.
Symbol(String)
Symbol(description: String )
Creates a new symbol. Note that it must be called without new.
Symbols created via this method are always distinct.
Parameters:
description - A description for this symbol.
Method Details
for(String) - Variant 1
static for(key: String ): Symbol
Obtains a symbol from the global registry. If no symbol exists for the key within the registry a new symbol is
created and stored in the global registry.
Parameters:
key - The key for a symbol within the global registry.
Returns:
The found or newly created symbol.
API Version:
Available from version 21.2.
keyFor(Symbol)
static keyFor(symbol: Symbol ): String
Returns the key within the global symbol registry under which the given symbol is stored.
Parameters:
symbol - The symbol to look for.
Returns:
The key for the given symbol if the symbol is known to the global registry, else return undefined.