Javatpoint Logo
Javatpoint Logo

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




Please Share

facebook twitter google plus pinterest

B.Tech / MCA


Learn Latest Tutorials