Checking if a key exists in a map

suggest change

To check if a key exists in a Map, use the .has() method:

map.has(key);

Example:

const map = new Map([[1, 2], [3, 4]]);
console.log(map.has(1)); // true
console.log(map.has(2)); // false

Feedback about page:

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



Table Of Contents