typescript map contains key code example
Example 1: js check if map contains key
const map1 = new Map();
map1.set('bar', 'foo');
console.log(map1.has('bar'));
// expected output: true
console.log(map1.has('baz'));
// expected output: false
Example 2: node map has value
let myMap = new Map();
myMap.set("key1", "value1");
myMap.set("key2", "value2");
console.log(myMap.has("key1")); // true
console.log(myMap.has("key2")); // true
console.log(myMap.get("key1")); // value1
console.log(myMap.get("key2")); // value2
// NOTE: DO NOT try to access map values using [].
// myMap["key1"] = "value1";