The Reflect.defineProperty(object, property, descriptor) method

The Reflect.defineProperty() method defines a new property directly on an object or modifies an existing property on an object. It returns a Boolean value indicating whether the operation was successful or not.

It's similar to the Object.defineProperty() method. The difference is that the Reflect.defineProperty() method returns a Boolean, whereas the Object. defineProperty() returns the modified object. If the Object.defineProperty() method fails to modify or define an object property, then it throws an exception, whereas the Reflect.defineProperty() method returns a false result. The Reflect.defineProperty() method takes in three arguments:

  • The first argument is the object ...

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.