JS Built-ins
← Map22 / 55
Maphasbeginner

Map has() β€” missing key

πŸ“– Usage Example
const m = new Map([['a', 1]])
m.has('a')   // β†’ true
m.has('z')   // β†’ false

Use Map.has() to check whether a key exists in the map.

Map.prototype.has()

has() returns false for a key not in the Map.

Challenge: Verify that has() returns false for a missing key.

πŸ’‘ Hints (1)
  • β€’ has() returns false (not undefined) for missing keys