Name

Object.getOwnPropertyNames() — return the names of non-inherited properties

Availability

ECMAScript 5

Synopsis

Object.getOwnPropertyNames(o)

Arguments

o

An object

Returns

An array that contains the names of all non-inherited properties of o, including non-enumerable properties.

Description

Object.getOwnPropertyNames() returns an array that contains the names of all non-inherited properties of o, including non-enumerable properties. See Object.keys() for a function that returns only the names of enumerable properties.

Note that this is not a method to be invoked on an object: it is a global function and you must pass an object to it.

Example

Object.getOwnPropertyNames([])   // => ["length"]: "length" is non-enumerable

Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.