JavaScript: Object.getOwnPropertyDescriptor

By Xah Lee. Date: . Last updated: .
Object.getOwnPropertyDescriptor( obj, key)
Return the Property Descriptor of key of object obj. If the property doesn't exist, return undefined. If obj is not a object, it is first converted to a object type.

Tip: to throw error if argument is not a object, use Reflect.getOwnPropertyDescriptor

// get the attributes of a property
const x = {"p":4};
console.log( Object.getOwnPropertyDescriptor(x, "p") );
// → { value: 4, writable: true, enumerable: true, configurable: true }

Get Descriptors of All Properties

Object.getOwnPropertyDescriptors

JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS Obj Ref

Object Object

prototype