Home » JavaScript Reflect defineProperty() Method

JavaScript Reflect defineProperty() Method

by Online Tutorials Library

JavaScript Reflect.defineProperty() Method

The static method Reflect.defineProperty() allows the precise addition to or modification of a property on an object. The Reflect.defineProperty() method returns a Boolean value which indicates that whether or not the property was successfully defined.

Syntax

Parameter

target: It is the target object which defines the property.

propertyKey: It is the name of the property to be defined or modified.

Attributes: It is the attributes for the property being defined or modified.

Return value:

This method returns a Boolean value which indicates that whether or not the property was successfully defined.

Exceptions

This exception will throw a TypeError if the target is not an Object.

Example 1

Output:

Object {  }  

Example 2

Output:

 Object {  }    true  

Example 3

Output:

 "property1 created!"    42    12  

Next TopicJavaScript Reflect

You may also like