`Map` accepts arbitrary keys and maintains insertion order. `Set` enforces uniqueness. `WeakMap` only accepts objects as keys and does not prevent garbage collection.
js const cache = new WeakMap(); const seen = new Set(["0x1", "0x2"]);
100 XP to Apprentice
Keyed collections and garbage collection semantics.
AI translates the explanation and quiz text while preserving code and answer scoring.
`Map` accepts arbitrary keys and maintains insertion order. `Set` enforces uniqueness. `WeakMap` only accepts objects as keys and does not prevent garbage collection.
js const cache = new WeakMap(); const seen = new Set(["0x1", "0x2"]);
1. What can be used as keys in a JavaScript Map?
2. Why use WeakMap for object-keyed metadata?
3. What does a Set enforce?