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
Syntax
Object.getOwnPropertyNames(obj)
Parameters
| Parameter | Description |
|---|---|
obj |
The object to inspect or change. |
Return value
An array of strings.
Examples
const arr = ["a", "b"];
console.log(Object.keys(arr), Object.getOwnPropertyNames(arr));
Output
[ '0', '1' ] [ '0', '1', 'length' ]
console.log(Object.getOwnPropertyNames(Math).slice(0, 5));
Output
[ 'abs', 'acos', 'acosh', 'asin', 'asinh' ]
Version history
| Version | Change |
|---|---|
| JavaScript ES5 | Added |
Related
Object.keys()· Return an array of an object's own enumerable property names, in insertion order (integer keys first).Object.getOwnPropertyDescriptor()· Return the descriptor (value, writable, enumerable, configurable or get/set) of one own property.- JavaScript Objects · tutorial