JavaScript: Map.prototype.has

By Xah Lee. Date: . Last updated: .

New in ES2015.

Map.prototype.has(key)

Return true if key exist. Else, false.

// check existence
var m = new Map([ [4, "n4"], [5, "n5"] ]);
console.log(m.has (5)); // true
console.log(m.has (99)); // false

Reference

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

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/from Map
Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.