Object.keys()

ES5+

Returns an array of a given object's own enumerable property names.

Syntax

Object.keys(obj)

Parameters

obj Object

The object whose enumerable own property names are to be returned

Return Value

Array

An array of strings representing the object's enumerable properties

Examples

JavaScript
const obj = { a: 1, b: 2, c: 3 };
console.log(Object.keys(obj));
Output:
// ['a', 'b', 'c']

Related Methods