De entries() funtie geeft een nieuw Array Iterator object dat de key/value paren bevat voor elk onderdeel van de array.
var a = ['a', 'b', 'c']; var iterator = a.entries(); console.log(iterator.next().value); // [0, 'a'] console.log(iterator.next().value); // [1, 'b'] console.log(iterator.next().value); // [2, 'c']
Syntax
a.entries()
Return waarde
Een nieuw Array iterator object.
Voorbeeldjes
De for…of loop
var a = ['a', 'b', 'c'];
var iterator = a.entries();
for (let e of iterator) {
console.log(e);
}
// [0, 'a']
// [1, 'b']
// [2, 'c']
Specificaties
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Array.prototype.entries' in that specification. |
Standard | Standaard definitie. |
| ECMAScript 2017 Draft (ECMA-262) The definition of 'Array.prototype.entries' in that specification. |
Draft |
Ondersteunende browsers
| Functie | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basis ondersteuning | 38 | 28 (28) | No support | 25 | 7.1 |
| Functie | Android | Chrome voor Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basis ondersteuning | No support | No support | 28.0 (28) | No support | No support | 8.0 |