JavaScript: Object.getOwnPropertyDescriptors

By Xah Lee. Date: . Last updated: .

New in JS2017.

Object.getOwnPropertyDescriptors( obj)
Return Property Descriptor of all own properties of a object. The return value is a object, has this form { k1: descriptor1, k2: descriptor2, etc }.
If obj is not a object, it is first converted to a object type.
// object with a string key and symbol key
const xx = {
 "p":3,
 [Symbol()]:4
};

console.log(
Object.getOwnPropertyDescriptors(xx)
);

// prints
// { p:
//    { value: 3, writable: true, enumerable: true, configurable: true },
//   [Symbol()]:
//    { value: 4, writable: true, enumerable: true, configurable: true }
// }
// If obj is not a object, it is first converted to a object type
console.log( Object.getOwnPropertyDescriptors(3) );
// prints
// {}
JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS Obj Ref

Object Object

prototype