Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript keys() Method

JavaScript keys() Method

Array Object Reference JavaScript Array object

Example

Create an array iterator object from the array fruit that contains the keys of the array:

var

fruits

=

[

"

Banana

"

,

"

Orange

"

,

"

Apple

"

,

"

Mango

"

]

;

fruits

.

keys

(

)

;

Try it »


Definition and Usage

The keys() method is used to create an iterable object containing the keys of an array from an array.

Returns true if the object is an array, otherwise returns false.


Browser support

The numbers in the table indicate the first browser version that supports this method.

Method
keys() 38.0 12.0 28.0 8 25.0

Syntax


array.keys()

Parameters

No parameters.

Technical Details

Return value: An array iterator object.
JavaScript version: ECMAScript 6

Array Object Reference JavaScript Array object