Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
JavaScript
/
WeakMap and WeakSet
Why do WeakMap and WeakSet omit iteration and size?
from WeakMap and WeakSet
Node 24
intermediate
1 min
Why do WeakMap and WeakSet omit iteration and size?
Enumeration would expose garbage-collection-dependent liveness and make ordinary program results nondeterministic.
Weak collections store entries in insertion order but hide that order only for speed.
JavaScript objects cannot be iterated by any built-in collection.
Calling size would force every value to become a primitive.
Check
Ask AI about this kata
Report an error
previous kata
What does this program print?
Predict the output
next kata
Review a generated request cache
Review AI code
A new version is available
Reload