Lambda saysWeakMap and WeakSet hold object keys weakly, letting them be garbage-collected.
A WeakMap/WeakSet only holds objects, and holds them weakly: if nothing else references the key, it can be garbage-collected (and removed automatically). That makes them ideal for attaching private data or metadata to objects without causing memory leaks. They're not iterable and have no size.
Power-ups you unlock
Keys must be objects, held weakly
Entries vanish when keys are GC’d
No iteration, no size
Great for private/metadata without leaks
The Mutator attacks — common mistakes
Expecting to iterate a WeakMap
Using primitive keys (not allowed)
Reaching for WeakMap when a Map is what you need
Boss battleAttach private data to an object via a WeakMap.