In general, a map is an object that associates keys and values.

var gifts = { 'first': 'partridge', 'second': 'turtledoves', 'fifth': 'golden rings' }; 
var nobleGases = { 2: 'helium', 10: 'neon', 18: 'argon', };
var gifts = Map();
gifts['first'] = 'partridge';
gifts['second'] = 'turtledoves';
gifts['fifth'] = 'golden rings';
var nobleGases = Map();
nobleGases[2] = 'helium';
nobleGases[10] = 'neon';
nobleGases[18] = 'argon';
  • Both keys and values can be any type of object.
  • Each key occurs only once, but you can use the same value multiple times.
  • If you look for a key that isn’t in a map, you get a null in return.
  • Use .length to get the number of key-value pairs in the map.
  • To create a map that’s a compile-time constant, add const before the map literal.

Map — Structure map

Clickable & Draggable!

Map — Related pages: