JavaScript: Map.prototype.get

By Xah Lee. Date: . Last updated: .

New in ES2015.

Map.prototype.get(key)

Return the value of the key key.

If key isn't found, return undefined.

var m = new Map([ [4, "n4"], [5, "n5"] ]);

// get the value of a key
console.log(m.get (5)); // "n5"

console.log(m.get (99)); // undefined

Reference

ECMAScript 2015 §Keyed Collection#sec-map.prototype.get

Map Topic

  1. JavaScript: the Map Object Tutorial
  2. JavaScript: Map Object
  3. JavaScript: Map.prototype
  4. JavaScript: Iterate Over Map Object
  5. JavaScript: Convert Object to Map Data Type
Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.