Skip to main content
Version: 3.28.0

Array.prototype.keys()

The keys() method returns a new Array Iterator object that contains the keys for each index in the array.

Syntax

keys()

Return value

A new Array iterator object.

Description

When used on sparse arrays, the keys() method iterates empty slots as if they have the value undefined.

The keys() method is generic. It only expects the this value to have a length property and integer-keyed properties.