TypeScript · Middle · Question 69 of 75
When is Map<K, V> a better choice than an index signature object?
- ✓Correct answer: When keys aren't strings, entries are added/removed often, or keys could collide with prototype names like
constructor - 2Never - objects are always faster
- 3Only for numeric values
Explanation
map.get(key) is typed as V | undefined, which also forces handling missing keys.