JS Built-ins
WeakRefintermediate

WeakRef β€” primitive throws

πŸ“– Usage Example
const ref = new WeakRef({})
typeof ref  // β†’ 'object'

WeakRef is an object type used for memory-sensitive caching scenarios.

WeakRef Primitive

new WeakRef(42) throws a TypeError because WeakRef only accepts objects.

Challenge: Verify that passing a primitive throws.

πŸ’‘ Hints (1)
  • β€’ WeakRef only accepts objects (including arrays and functions), not primitives like numbers or strings.