Advanced JavaScript / Map & Set
Map & Set
A Map pairs any key with a value; a Set holds only unique values.
`Map` is like an object, but keys can be any type — not just strings — and insertion order is always preserved. `Set` stores a collection where every value is guaranteed unique; adding a duplicate is silently ignored. Both are iterable and track their own `.size`.
Codeeditable — Run executes your edits
Loading...
Console
Output will appear here
Visualization
State
Step through — the console panel shows what's happening
Why?
The second seen.add("a") is a duplicate — Set silently ignores it, so size stays at 2 instead of climbing to 3.