JS Built-ins
WeakSetaddintermediate

WeakSet.prototype.add() β€” chaining

πŸ“– Usage Example
const ws = new WeakSet()
const fn = () => {}
ws.add(fn)
ws.has(fn)  // β†’ true

Functions are objects and can be stored in a WeakSet.

WeakSet add() Chain

Because add() returns the set, you can chain multiple adds.

Challenge: Verify chained adds work.

πŸ’‘ Hints (1)
  • β€’ add() returns the WeakSet, enabling method chaining.