![]() |
VOOZH | about |
The Symbol.keyFor() is an inbuilt method in JavaScript that is used to retrieve the key which has been shared with the given symbols and this key is retrieved from the global symbol registry.
Syntax:
Symbol.keyFor(sym);
Here "Symbol" is the symbol that is to be searched into the runtime-wide symbol registry.
Parameters: This method accepts a parameter "sym" which is the symbol for which the key is to be found.
Return value: This method returns a string representing the key for the given symbol found in the global registry otherwise it returns undefined. JavaScript code to show the working of this method.
Example 1: In this example, we will use Symbol keyFor() Method.
Geeks 123 gfg 789
Example 2: In this example, we will use Symbol keyFor() Method.
undefined undefined
Reference: https://devdocs.io/javascript/global_objects/symbol/keyfor