Curriculum Collections Maps exercise 3 · mcq
Maps
TypeScript: scores["nope"] gives undefined for a missing key.
In Go, a map lookup ALWAYS returns a value — even for keys that
were never inserted. What does v hold below?
``go
scores := map[string]int{"alan": 7}
v := scores["nope"]
``
TypeScript reference
About this theme
map[K]V. Like a TS Record<K, V> or Map<K, V>. Lookup with comma-ok: v, ok := m[key]. Iteration order is undefined — every range yields a different ordering. Maps are reference types; passing a map to a function shares it.