JS Built-ins
← Map16 / 55
Mapgetbeginner

Map get() β€” existing 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(key) returns the value associated with the key.

Challenge: Verify that get() returns the stored value.

πŸ’‘ Hints (1)
  • β€’ get() returns the value for the given key, or undefined if the key does not exist