JavaScript Object.getOwnPropertyDescriptors()

Definition and Usage

Object.getOwnPropertyDescriptors() The method returns the descriptors of all properties of the object.

Object.getOwnPropertyDescriptors() 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 descriptors
let descriptors = Object.getOwnPropertyDescriptors(person);

Try it yourself

Syntax

Object.getOwnPropertyDescriptors(object)

Parameter

Parameter Description
object Required. The object to get the property descriptor from.

Return Value

Type Description
Object Object that contains all property descriptors.

Browser Support

Object.getOwnPropertyDescriptors() Is ECMAScript5 (ES5) feature.

Since July 2013, all modern browsers fully support 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