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

Chrome40
Safari9
Firefox36
OperaYes

Example 1

Test it Now

Output:

true

Example 2

Test it Now

Output:

true





Latest Courses