JavaScript Array entries()
Example
Create an Array Iterator, and then iterate over the key/value pairs:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
const f = fruits.entries();
for (let x of f) {
document.getElementById("demo").innerHTML += x;
}
Try it Yourself »
Description
The entries() method returns an Array Iterator object with key/value pairs:
[0, "Banana"]
[1, "Orange"]
[2, "Apple"]
[3, "Mango"]
The entries() method does not change the original array.
Syntax
array.entries()
Parameters
| NONE |
Return Value
| Type | Description |
| Iterable | An array like iterable with key/value pairs. |
Related Pages:
Browser Support
entries() is an ECMAScript6 (ES6) feature.
ES6 (JavaScript 2015) is supported in all modern browsers since June 2017:
| Chrome 51 | Edge 15 | Firefox 54 | Safari 10 | Opera 38 |
| May 2016 | Apr 2017 | Jun 2017 | Sep 2016 | Jun 2016 |
entries() is not supported in Internet Explorer.
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.