JS Built-ins
Mapbeginner

Map Constructor β€” empty Map

πŸ“– Usage Example
const m1 = new Map()
const m2 = new Map([['x', 1], ['y', 2]])
console.log(m2.size) // β†’ 2

Use the Map constructor to create a new map, optionally passing an array of entries.

Map Constructor

new Map() creates an empty Map with size 0.

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

πŸ’‘ Hints (1)
  • β€’ new Map() with no arguments creates an empty Map