JavaScript Reflect.set() method

The static Reflect.set() method is used to set the value of an object's property. It returns true if the property was successfully set. Otherwise, it returns false.

Syntax:

Parameters:

Obj: It is the target object on which to set the property.

Key: It is the name of the property to set.

value: It is the value to set.

Receiver: It is the value of this provided for the call to target if a setter is encountered.

Return value:

This method returns a Boolean which indicates whether or not setting the property was successful.

Exceptions:

A TypeError, if the target is not an Object.

Browser Support:

Chrome49
Edge12
Firefox42
Opera36

Example 1

Output:

"gosse"

Example 2

Output:

32

Example 3

Output:

7
4




Latest Courses