Il metodo entries()
restituisce un nuovo oggetto Array Iterator
contenente delle coppie chiave/valore per ogni indice presente nell'array.
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.
Sintassi
a.entries()
Valore ritornato
Un nuovo oggetto iterator Array
.
Esempi
Utilizzo nel 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']
Specifiche
Specifica | Stato | Commento |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Array.prototype.entries' in that specification. |
Standard | Definizione iniziale. |
ECMAScript (ECMA-262) The definition of 'Array.prototype.entries' in that specification. |
Living Standard |
Compatibilità con il browser
BCD tables only load in the browser
The compatibility table in 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.