JavaScript Object.keys() Method
The Object.keys() static method returns an array of an object's own property names.
Description
The Object.keys() static method returns an array of the object's own enumerable property names. Inherited properties, non-enumerable properties and symbol keys aren't included. Integer-like keys are listed first in ascending order, then other strings in the order they were added.
Object.keys(obj).length is a quick way to count properties or check whether an object is empty.
Passing a primitive converts it to an object first, so Object.keys('ab') gives ['0', '1'], while null and undefined throw a TypeError. To include symbol keys or non-enumerable properties, use Reflect.ownKeys().
Syntax
Object.keys(obj)Parameters
- objThe object to work with.
Return Value
An array of the object's own enumerable string property names.
Example
Browser Support
The following information will show you the current browser support for the Object.keys() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





