Map.prototype.has()
Metoda has()
zwraca Boolean, który określa czy element o podanym kluczu istnieje.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Składnia
myMap.has(key);
Parametry
- key
- Wymagany. Klucz elementu, którego istnienie w
Mapie
zostanie sprawdzone.
Zwracana wartość
- Boolean
-
true
, jeśli dany element istnieje wMapie
- w przeciwnym wypadkufalse
.
Przykłady
Używanie metody has
var myMap = new Map();
myMap.set('bar', "foo");
myMap.has('bar'); // zwraca true
myMap.has('baz'); // zwraca false
Specyfikacja
Specyfikacja | Status | Komentarz |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Map.prototype.has' in that specification. |
Standard | Initial definition. |
ECMAScript (ECMA-262) The definition of 'Map.prototype.has' in that specification. |
Living Standard |
Kompatybilność z przeglądarkami
BCD tables only load in the browser