Checking if a key exists in a map
suggest changeTo 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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents