JS Built-ins
← Map17 / 55
Mapgetbeginner

Map get() β€” missing key

πŸ“– Usage Example
const m = new Map([['name', 'Alice']])
m.get('name')    // β†’ 'Alice'
m.get('missing') // β†’ undefined

Use Map.get() to retrieve the value associated with a key.

Map.prototype.get()

get() returns undefined when the key is not in the Map.

Challenge: Verify that get() returns undefined for a missing key.

πŸ’‘ Hints (1)
  • β€’ get() returns undefined for keys that do not exist in the Map