JavaScript · Junior · Question 47 of 75
How does Map differ from a plain object?
- ✓Correct answer:
Mapkeys can be any values, and insertion order is preserved - 2
Mapcan store only string keys, while an object can store any values - 3
Mapis immutable: pairs can't be added after creation
Explanation
Object keys are strings or symbols (the number 1 becomes '1'), and there are inherited properties. Map accepts objects as keys, has size and get/set/has/delete, and is convenient for frequent additions and removals.