Array.prototype.entries()
Die entries()
Methode gibt ein neues Array Iterator
Objekt zurück, das Schlüssel-Wert-Paare für jeden Index im Array enthält.
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
arr.entries()
Rückgabewert
Ein neues Array
-iterator Objekt.
Beispiele
Einsatz einer for…of Schleife
var a = ['a', 'b', 'c'];
var iterator = a.entries();
for (let e of iterator) {
console.log(e);
}
// [0, 'a']
// [1, 'b']
// [2, 'c']
Spezifikationen
Spezifikation | Status | Kommentar |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) Die Definition von 'Array.prototype.entries' in dieser Spezifikation. |
Standard | Initiale Definition. |
ECMAScript (ECMA-262) Die Definition von 'Array.prototype.entries' in dieser Spezifikation. |
Lebender Standard |
Browserkompatibilität
BCD tables only load in the browser