Clearing a map

suggest change

To remove all elements from a Map, use the .clear() method:

map.clear();

Example:

const map = new Map([[1, 2], [3, 4]]);
console.log(map.size); // 2
map.clear();
console.log(map.size); // 0
console.log(map.get(1)); // undefined

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents