89
JavaScript Symbol.for() Method
The JavaScript Symbol.for() method is used to search for existing symbol in a runtime-wide symbol registry with the provided key and returns if it found. Otherwise, a new symbol gets created with this key.
Syntax
Parameters
Key: The Keys to the symbol.
Return value
Existing symbol with the given key if found otherwise, a new symbol is created and returned.
Browser Support
Chrome | 40 |
Safari | 9 |
Firefox | 36 |
Opera | Yes |
Example 1
Output:
true
Example 2
Output:
true
Next TopicJavaScript Symbol