Metoda get()
zwraca podany element Mapy
.
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.get(key);
Parametry
- key
- Wymagany. Klucz elementu, który ma zostać zwrócony.
Zwracana wartość
Element powiązany z danym kluczym lub undefined
, jeśli klucz nie został odnaleziony.
Przykłady
Używanie metody get
var myMap = new Map(); myMap.set('bar', 'foo'); myMap.get('bar'); // zwraca "foo". myMap.get('baz'); // zwraca undefined.
Specyfikacja
Specyfikacja | Status | Komentarz |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Map.prototype.get' in that specification. |
Standard | Definicja początkowa. |
ECMAScript Latest Draft (ECMA-262) The definition of 'Map.prototype.get' in that specification. |
Draft |
Kompatybilność z przeglądarkami
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 |
---|---|---|---|---|---|---|
Basic support | 38 | 12 | 13 | 11 | 25 | 8 |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | Opera Android | iOS Safari | Samsung Internet |
---|---|---|---|---|---|---|---|
Basic support | 38 | 38 | 12 | 14 | 25 | 8 | Yes |
Zobacz również
Autorzy i etykiety dokumentu
Etykiety:
Autorzy tej strony:
MarekHuckmann
Ostatnia aktualizacja:
MarekHuckmann,