The JavaScript Reflect.set() method is used to assign a value to a property of an object. It returns a Boolean value indicating whether the property was successfully updated.
In this chapter, you will learn how to use the Reflect.set() method to add and modify properties of objects and arrays.
The JavaScript Reflect.set() method assigns a value to a specified property of an object. It works similarly to the assignment operator (=) but returns a Boolean value indicating whether the operation was successful.
Use the following syntax to set the value of a property:
The Reflect.set() method returns a Boolean value.
The following examples demonstrate how to use the Reflect.set() method.
In this example, we use the Reflect.set() method to assign a value to a specific index of an array.
Output:
"gosse"
In this example, we use the Reflect.set() method to add a new property and assign a value to an object.
Output:
32
In this example, we use the Reflect.set() method to add properties to multiple objects and access their values.
Output:
7 4
| Browser | Version |
|---|---|
| Chrome | 49 |
| Edge | 12 |
| Firefox | 42 |
| Opera | 36 |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India