jskatas.org Continuously Learn JavaScript. Your Way.

Map: initialize

Initializing a map with values.

Donate to NGO Julenka. Support Ukranians in need. Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.

initialize a Map

  • a new Map() is empty, has size=0
  • init Map with [[]] has a size=1
  • init a Map with [[1]] is the same as map.set(1, void 0)
  • init Map with multiple key+value pairs
  • keys are unique, the last one is used
  • init Map from an Object, is a bit of work