Map.prototype.has()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Thehas() method ofMap instances returns a boolean indicating whether an entry with the specified key exists in thisMap or not.
In this article
Try it
const map = new Map();map.set("bar", "foo");console.log(map.has("bar"));// Expected output: trueconsole.log(map.has("baz"));// Expected output: falseSyntax
js
has(key)Parameters
Return value
Returnstrue if an entry with the specified key exists in theMap object; otherwisefalse.
Examples
>Using has()
js
const myMap = new Map();myMap.set("bar", "foo");console.log(myMap.has("bar")); // trueconsole.log(myMap.has("baz")); // falseSpecifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-map.prototype.has> |