Object.getOwnPropertyDescriptor()
Example
// Create an Object
const person = {
firstName: "John",
lastName: "Doe",
age: 50,
eyeColor: "blue"
};
// Get Properties
let descriptor = Object.getOwnPropertyDescriptor(person);
Try it Yourself »
Description
The Object.getOwnPropertyDescriptor()
method returns the property descriptors of an object.
The Object.getOwnPropertyDescriptor()
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.getOwnPropertyDescriptor(object)
Parameters
Parameter | Description |
object | Required. An iterable object. |
Return Value
Type | Description |
Array | An interable array containing the keys of the object. |
Browser Support
Object.getOwnPropertyDescriptor()
is an ECMAScript5 (ES5) feature.
ES5 (JavaScript 2009) is fully supported in all modern 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 |