JS: Map.prototype.delete

By Xah Lee. Date: . Last updated: .

New in JS2015.

mapObj.delete(key)
Deletes the entry of key in mapObj. Return true if found, else false.
const xx = new Map([[3, "n3"], [4, "n4"], [5, "n5"]]);

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

console.log(xx.delete(99) === false);

console.log(xx); // Map { 3 => 'n3', 4 => 'n4' }
BUY ΣJS JavaScript in Depth