Symbol.keyFor Function (JavaScript)

Returns the key for a specified symbol.

Syntax

Symbol.keyFor(sym);  

Parameters

sym
Required. The symbol object.

Remarks

This method searches for the symbol in the global symbol registry.

Example

// Local symbol  
var sym1 = Symbol("desc");  
// Global symbol  
var sym2 = Symbol.for("desc");  

console.log(Symbol.keyFor(sym1)):  
console.log(Symbol.keyFor(sym2));  

// Output:  
// undefined  
// desc  

Requirements

Supported in Microsoft Edge (Edge browser). Also supported in Store apps (Microsoft Edge on Windows 10). See Version Information.
Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Not supported in Windows 8.1.