JS Built-ins
Symbolintermediate

Symbol() β€” cannot use new

πŸ“– Usage Example
Symbol('ok')   // works fine
try {
  new Symbol()  // TypeError!
} catch (e) {
  console.log(e instanceof TypeError)  // β†’ true
}

Symbol is a primitive factory β€” calling it with new throws a TypeError.

Symbol Cannot Be Constructed with new

Unlike most built-ins, Symbol is a function β€” calling it with new throws a TypeError.

Challenge: Confirm that new Symbol() throws.

πŸ’‘ Hints (1)
  • β€’ Wrap the `new Symbol()` call in an arrow function for toThrow().