keys Method (Array) (JavaScript)

Returns an iterator that returns the index values of the array.

Syntax

arrayObj.keys();  

Parameters

arrayObj
Required. The array object.

Remarks

Example

The following example shows how to get the key values of an array.

var k = ["a", "b", "c"].keys();  
// k.next().value == 0  
// k.next().value == 1  
// k.next().value == 2   

Requirements

Supported in Microsoft Edge (Edge browser). Also supported in Store apps (Microsoft Edge on Windows 10). See Version Information.
Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Not supported in Windows 8.1.