JS Built-ins
← Map10 / 55
Mapsizebeginner

Map size β€” is a number

πŸ“– Usage Example
const m = new Map([['a', 1], ['b', 2]])
console.log(m.size)   // β†’ 2
m.set('c', 3)
console.log(m.size)   // β†’ 3

Read Map.size to get the number of key-value pairs in the map.

Map.prototype.size

The size property is always a non-negative integer.

Challenge: Verify that typeof new Map().size is 'number'.

πŸ’‘ Hints (1)
  • β€’ size is always a non-negative integer