Map.prototype.delete()
map.delete(key)
Removes the entry with the given key. clear() empties the whole Map.
Parameters
- key – the key of the entry to remove.
Return value
true when the entry existed and was removed, otherwise false.
Examples
const logins = new Map([['jane', '10:02'], ['peter', '10:15']]);
console.log(logins.delete('jane'), logins.delete('eve'), logins.size);
logins.clear();
console.log(logins.size);
Output:
true false 1 0
Things to watch out for
- Deleting entries while going through a Map with a
for...ofloop is fine – the loop no longer returns the deleted entries.
Browser support
Baseline – widely available: works in all major browsers and has for a long time (since 2015 at the latest). Since version: Chrome 38, Firefox 13, Safari 8; Node.js 0.12.0. As of October 2026 (MDN browser-compat-data).