Algorithms and Data Structures · Junior · Question 15 of 75
When is a Map a better choice than a plain object for a dictionary?
- ✓Correct answer: When keys are not strings, or entries are added and removed often
- 2When there are fewer than ten keys
- 3When the data has to be serialized with
JSON.stringify
Explanation
Map accepts keys of any type (objects, numbers), keeps insertion order, has size and is optimized for frequent additions and deletions. A plain object converts keys to strings and inherits keys from its prototype.