Die has()
Methode gibt einen boolean zurück, welcher angibt, ob ein spezieller Schlüssel vorhanden ist oder nicht.
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.
Syntax
myMap.has(schlüssel);
Parameter
- schlüssel
- Der Schlüssel, auf dessen Präsenz in dem
Map
Objekt geprüft wird.
Return value
- Boolean
- Gibt
true
zurück, wenn ein Element mit Schlüssel in demMap
Objekt existiert, andernfallsfalse
.
Beispiele
Einsatz der has
Methode
var myMap = new Map(); myMap.set('bar', "foo"); myMap.has('bar'); // returns true myMap.has('baz'); // returns false
Spezifikationen
Spezifikation | Status | Kommentar |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) Die Definition von 'Map.prototype.has' in dieser Spezifikation. |
Standard | Initiale Definition. |
ECMAScript Latest Draft (ECMA-262) Die Definition von 'Map.prototype.has' in dieser Spezifikation. |
Entwurf |
Browserkompatibilität
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Grundlegende Unterstützung | 38 | 12 | 13 | 11 | 25 | 8 |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | Opera Android | iOS Safari | Samsung Internet |
---|---|---|---|---|---|---|---|
Grundlegende Unterstützung | 38 | 38 | 12 | 14 | 25 | 8 | Ja |
Siehe auch
Schlagwörter des Dokuments und Mitwirkende
Schlagwörter:
Mitwirkende an dieser Seite:
schlagi123
Zuletzt aktualisiert von:
schlagi123,