Metoda keys()
zwraca nowy obiekt typu Iterator, który zawiera klucze dla każdego elementu w Mapie
. Można się do nich odnieść w takiej kolejności, jakiej zostały wstawione.
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.keys()
Zwracana wartość
Nowy iterator obiektu typu Map
Przykłady
Używanie keys()
var myMap = new Map();
myMap.set('0', 'foo');
myMap.set(1, 'bar');
myMap.set({}, 'baz');
var mapIter = myMap.keys();
console.log(mapIter.next().value); // "0"
console.log(mapIter.next().value); // 1
console.log(mapIter.next().value); // Object
Specyfikacja
Specyfikacja | Status | Komentarz |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Map.prototype.keys' in that specification. |
Standard | Definicja początkowa. |
ECMAScript (ECMA-262) The definition of 'Map.prototype.keys' in that specification. |
Living Standard |
Kompatybilność z przeglądarkami
BCD tables only load in the browser
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.