--- title: Array.prototype.entries() slug: Web/JavaScript/Reference/Global_Objects/Array/entries translation_of: Web/JavaScript/Reference/Global_Objects/Array/entries ---
{{JSRef}}

Il metodo entries() restituisce un nuovo oggetto Array Iterator contenente delle coppie chiave/valore per ogni indice presente nell'array.

{{EmbedInteractiveExample("pages/js/array-entries.html")}}

Sintassi

a.entries()

Valore ritornato

Un nuovo oggetto iterator {{jsxref("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
{{SpecName('ES2015', '#sec-array.prototype.entries', 'Array.prototype.entries')}} {{Spec2('ES2015')}} Definizione iniziale.
{{SpecName('ESDraft', '#sec-array.prototype.entries', 'Array.prototype.entries')}} {{Spec2('ESDraft')}}  

Compatibilità con il browser

{{Compat("javascript.builtins.Array.entries")}}

Vedi anche