JS Built-ins
Mapsizebeginner

Map size β€” empty Map

πŸ“– 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 returns the number of key-value pairs. An empty Map has size 0.

Challenge: Verify that new Map().size equals 0.

πŸ’‘ Hints (1)
  • β€’ An empty Map has size 0