.has js code example
Example 1: node map has value
let myMap = new Map();
myMap.set("key1", "value1");
myMap.set("key2", "value2");
console.log(myMap.has("key1"));
console.log(myMap.has("key2"));
console.log(myMap.get("key1"));
console.log(myMap.get("key2"));
Example 2: .has js
const map1 = new Map();
map1.set('bar', 'foo');
console.log(map1.has('bar'));
console.log(map1.has('baz'));
Example 3: .has js
The has() function of the map object accepts a key in string format and returns a boolean value of true if the specified key exists. Otherwise, the function returns false.