JS Built-ins
← Map21 / 55
Maphasbeginner

Map has() β€” existing 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(key) returns true if the key exists in the Map.

Challenge: Verify that has() returns true for an existing key.

πŸ’‘ Hints (1)
  • β€’ has() returns true if the Map contains the key