Home » JavaScript Symbol for() Method

JavaScript Symbol for() Method

by Online Tutorials Library

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

Test it Now

Output:

true  

Example 2

Test it Now

Output:

true  

Next TopicJavaScript Symbol

You may also like