JS Built-ins
← Map18 / 55
Mapgetbeginner

Map get() β€” after overwrite

πŸ“– 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()

After setting a key twice, get() returns the latest value.

Challenge: Verify that get() returns the updated value after overwrite.

πŸ’‘ Hints (1)
  • β€’ set() with an existing key updates the value; get() always returns the latest value