Object.getOwnPropertyDescriptor

Gets the own property descriptor of the specified object. An own property descriptor is one that is defined directly on the object and is not inherited from the object’s prototype.

Syntax

getOwnPropertyDescriptor(object, propertyName)

Parameters

Return value

A property descriptor of the specified property, or undefined if the property does not exist.

Examples

let obj = { temperature: 37 }
Object.getOwnPropertyDescriptor(obj, "temperature")
{value: 37, writable: true, enumerable: true, configurable: true}