JavaScript entries() Method
Example
Create an iterable object from the array fruit that contains the key/value pairs of the array:
var
fruits
=
[
"
Banana
"
,
"
Orange
"
,
"
Apple
"
,
"
Mango
"
]
;
fruits
.
entries
(
)
;
Try it »
Definition and Usage
The entries() method returns an iterator object of an array that contains the key/value pairs (key/value) of the array.
In the iterator object, the array index serves as the key and the array element serves as the value.
[0, "Banana"]
[1, "Orange"]
[2, "Apple"]
[3, "Mango"]
Browser support
The numbers in the table indicate the first browser version that supports this method.
| Method | |||||
|---|---|---|---|---|---|
| entries() | 38.0 | 12.0 | 28.0 | 8 | 25.0 |
Syntax
array.entries()
Parameters
No parameters.
Technical Details
| Return value: | Array iterator object |
|---|---|
| JavaScript version: | ECMAScript 6 |
JavaScript Array object