TypeScript · Middle · Question 69 of 75

When is Map<K, V> a better choice than an index signature object?

Explanation

map.get(key) is typed as V | undefined, which also forces handling missing keys.

Further reading

Problem with a question

TypeScript · Middle · question 69

Test yourself

Take the TypeScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz