ES8 - OwnPropertyDescriptor

This tutorial covers ES8 Object.getOwnPropertyDescriptors tutorials, examples introduced to latest javascript features, in ES8, ES2017, with examples.

javascript Object getOwnPropertyDescriptors

getOwnPropertyDescriptors() method in object finds complete information of a property and returns property descriptors.

This will be useful for real shallow copy of an object cloning, Before ES8, Object will be copied using Object.assign() which is not suitable for complex object graph.



Parameters and return type

  • Input is an object
  • return property descriptors of an given input object


const myobject = {
const descriptors = Object.getOwnPropertyDescriptors(myobject);

And the output is

  id: {
    value: '1',
    writable: true,
    enumerable: true,
    configurable: true
  name: {
    value: 'Tom',
    writable: true,
    enumerable: true,
    configurable: true


console.log(; //true
console.log(; //1
console.log(; // undefined
console.log(; // undefined
console.log(; // true
console.log(; // true

Descriptors allowed for each property are as follows

  • writable - the property allows to modify or not
  • value - the value of an property key
  • get - returns the getter function for the property if present,else undefined
  • set - setter function of the property, if present, else undefined
  • configurable - true, can be changed and will be delete from an object,else false.
  • enumerable - if true, will be treated as enumerable property and shown during iteration

Important points

  • It returns the own properties of an object
  • It does not consider properties from Object.protototype inheritance

Support This will support in latest browsers To support in older browsers, enable the following plugins in your project

  • polyfill
  • babel plugin