Array.prototype.entries()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since May 2018.
El método entries()
retorna un nuevo objeto Array Iterator
que contiene los pares clave/valor para cada índice de la matriz.
Pruébalo
Sintaxis
arr.entries()
Valor de retorno
Un nuevo objeto iterador Array
.
Ejemplos
Usando un bucle for…of
js
var a = ["a", "b", "c"];
var iterator = a.entries();
for (let e of iterator) {
console.log(e);
}
// [0, 'a']
// [1, 'b']
// [2, 'c']
Especificaciones
Specification |
---|
ECMAScript Language Specification # sec-array.prototype.entries |
Compatibilidad con navegadores
BCD tables only load in the browser