JavaScript · Middle · Question 30 of 75
How does WeakMap differ from Map?
- ✓Correct answer: Keys are only objects and don't prevent garbage collection; it can't be iterated
- 2
WeakMapis faster but holds at most 1000 entries at once - 3
WeakMapautomatically deletes entries after a set time
Explanation
If there are no other references to a key object, the entry disappears with it. That's why WeakMap has no size or iteration. Uses: private data for objects, a metadata cache for DOM nodes without memory leaks.