JS Built-ins
SymbolkeyForbeginner

Symbol.keyFor() β€” return type is string

πŸ“– Usage Example
const s = Symbol.for('x')
typeof Symbol.keyFor(s)   // β†’ 'string'

When a key is found, Symbol.keyFor() returns a string; otherwise it returns undefined.

Symbol.keyFor Return Type

When a key is found, Symbol.keyFor returns a string.

Challenge: Verify the type of the returned value.

πŸ’‘ Hints (1)
  • β€’ The result is either a string or undefined.