The Reflect.getOwnPropertyDescriptor(object, property) method

The Reflect.getOwnPropertyDescriptor() method is used to retrieve the descriptor of an object's property.

The Reflect.getOwnPropertyDescriptor() method is the same as the Object.getOwnPropertyDescriptor() method. The Reflect. getOwnPropertyDescriptor() method takes two arguments. The first argument is the object and the second argument is the property name.

Here is an example to demonstrate the Reflect.getOwnPropertyDescriptor() method:

var obj = { name: "Eden" }; var descriptor = Reflect.getOwnPropertyDescriptor(obj, "name"); console.log(descriptor.value); console.log(descriptor.writable); console.log(descriptor.enumerable); console.log(descriptor.configurable);

The output is ...

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.