Array.prototype.entries()
Metoda entries()
zwraca obiekt Iteratora
który zawiera parę klucz/wartość dla każdej pozycji w tablicy.
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
a.entries()
Zwracana wartość
Nowy iterator Tablicy
.
Przykłady
Użycie w pętli for…of
var a = ['a', 'b', 'c'];
var iterator = a.entries();
for (let e of iterator) {
console.log(e);
}
// [0, 'a']
// [1, 'b']
// [2, 'c']
Specyfikacja
Specyfikacja | Status | Komentarz |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Array.prototype.entries' in that specification. |
Standard | Initial definition. |
ECMAScript (ECMA-262) The definition of 'Array.prototype.entries' in that specification. |
Living Standard |
Kompatybilność w przeglądarkach
BCD tables only load in the browser