JavaScript Array keys()
Example
Create an Array Iterator object, containing the keys of the array:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
const keys = fruits.keys();
for (let of keys) {
text += x + "<br>";
}
Try it Yourself »
Definition and Usage
The keys() method returns an Array Iterator object with the keys of an array.
keys() does not change the original array.
Browser Support
The numbers in the table specify the first browser version that fully supports the method:
| Chrome 38 | Edge 12 | Firefox 28 | Safari 8 | Opera 25 |
| Oct 14 | Jul 2015 | Mar 2014 | Oct 2014 | Oct 2014 |
keys() is not supported in Internet Explorer.
Syntax
array.keys()
Parameter Values
No parameters.
Technical Details
| Return Value: | An Array Iterator object |
|---|---|
| JavaScript Version: | ECMAScript 6 |

