JavaScript (ES2026) reference · Object Methods

JavaScript Object.getOwnPropertyNames() Method

Return all own string property names, including non-enumerable ones that Object.keys() skips.

JavaScript (ES2026) Since ES5

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

Object.getOwnPropertyNames(obj)

Parameters

ParameterDescription
obj The object to inspect or change.

Return value

An array of strings.

Examples

Includes non-enumerable lengthTry it yourself
const arr = ["a", "b"];
console.log(Object.keys(arr), Object.getOwnPropertyNames(arr));

Output

[ '0', '1' ] [ '0', '1', 'length' ]
Inspect a built-inTry it yourself
console.log(Object.getOwnPropertyNames(Math).slice(0, 5));

Output

[ 'abs', 'acos', 'acosh', 'asin', 'asinh' ]

Version history

VersionChange
JavaScript ES5Added

Was this page helpful?