JavaScript Object.getOwnPropertyNames()
- Previous page getOwnPropertyDescriptors()
- Next page groupBy()
- Go back to the previous level JavaScript Object Reference Manual
Definition and usage
Object.getOwnPropertyNames()
The method returns an array containing all property names of the object.
Object.getOwnPropertyNames()
The method does not change the original object.
Related methods:
Object.defineProperty()
Add or modify properties.
Object.defineProperties()
Add or modify multiple properties.
Object.getOwnPropertyNames()
Returns all property names of the object.
Object.getOwnPropertyDescriptor()
Returns the descriptor of the property.
Object.getOwnPropertyDescriptors()
Returns the descriptors of all properties of the object.
Instance
// Create an object const person = { firstName: "Bill", lastName: "Gates", age: 50, eyeColor: "blue" }; // Get all property names let props = Object.getOwnPropertyNames(person);
Syntax
Object.getOwnPropertyNames(object)
Parameter
Parameter | Description |
---|---|
object | Required. Target object. |
Return value
Type | Description |
---|---|
Array | An array containing all the property names of the object. |
Browser support
Object.getOwnPropertyNames()
Is a feature of ECMAScript5 (ES5).
Since July 2013, all modern browsers have fully supported ES5 (JavaScript 2009):
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome 23 | IE/Edge 11 | Firefox 21 | Safari 6 | Opera 15 |
September 2012 | September 2012 | April 2013 | July 2012 | July 2013 |
- Previous page getOwnPropertyDescriptors()
- Next page groupBy()
- Go back to the previous level JavaScript Object Reference Manual