Map.prototype.has() - JavaScript | MDN
Try it
const map = new Map();
map.set("bar", "foo");
console.log(map.has("bar"));
// Expected output: true
console.log(map.has("baz"));
// Expected output: false
Syntax
Parameters
Return value
Returns true if an entry with the specified key exists in the Map object; otherwise false.
Examples
Using has()
js
const myMap = new Map();
myMap.set("bar", "foo");
console.log(myMap.has("bar")); // true
console.log(myMap.has("baz")); // false
Specifications
| Specification |
|---|
| ECMAScript® 2027 Language Specification # sec-map.prototype.has |