JS: Map.prototype.delete

By Xah Lee. Date: . Last updated: .

New in ES2015.

map_obj.delete(key)

Deletes the entry of key in map_obj.

Return true if found, else false.

const m = new Map([[3, "n3"], [4, "n4"], [5, "n5"] ]);

// delete a entry. return true if found
console.log(m.delete(5)); // true

console.log(m.delete(99)); // false

console.log(m); // Map { 3 => 'n3', 4 => 'n4' }

Reference

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

Map Topic

  1. JS: the Map Object Tutorial
  2. JS: Map Object
  3. JS: Map.prototype
  4. JS: Iterate Over Map Object
  5. JS: Convert Object to/from Map
Like what you read? Buy JavaScript in Depth