Object.getOwnPropertyDescriptors()
Example
// Create an Object
const person = {
firstName: "John",
lastName: "Doe",
age: 50,
eyeColor: "blue"
};
// Get Properties
let descriptors = Object.getOwnPropertyDescriptors(person);
Try it Yourself »
Description
The Object.getOwnPropertyDescriptors() method returns the property descriptors of an object.
The Object.getOwnPropertyDescriptors() method does not change the original object.
Related Methods:
Object.defineProperty() adds or changes one property.
Object.defineProperties() adds or changes many properties.
Object.getOwnPropertyNames() returns the property names of an object.
Object.getOwnPropertyDescriptor() returns the descriptor of a property.
Object.getOwnPropertyDescriptors() returns the descriptors of all properties.
Syntax
Object.getOwnPropertyDescriptors(object)
Parameters
| Parameter | Description |
| object | Required. The object to get the property descriptors from. |
Return Value
| Type | Description |
| Object | An object containing the property descriptors. |
Browser Support
Object.getOwnPropertyDescriptors() is an ECMAScript5 (ES5 2009) feature.
JavaScript 2009 is supported in all browsers since July 2013:
| Chrome 23 |
IE/Edge 11 |
Firefox 21 |
Safari 6 |
Opera 15 |
| Sep 2012 | Sep 2012 | Apr 2013 | Jul 2012 | Jul 2013 |