We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

The has() method returns a boolean indicating whether an element with the specified key exists or not.




Required. The key of the element to test for presence in the Map object.

Return value

Returns true if an element with the specified key exists in the Map object; otherwise false.


Using the has method

var myMap = new Map();
myMap.set('bar', "foo");

myMap.has('bar');  // returns true
myMap.has('baz');  // returns false


Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Map.prototype.has' in that specification.
Standard Initial definition.
ECMAScript Latest Draft (ECMA-262)
The definition of 'Map.prototype.has' in that specification.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support38121311258
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support38381214258 Yes

See also

Document Tags and Contributors

Contributors to this page: wbamberg, fscholz, jameshkramer, nmve, kdex, realityking
Last updated by: wbamberg,