Reflect.set()
The static Reflect.set()
method works like setting a
property on an object.
Syntax
Reflect.set(target, propertyKey, value)
Reflect.set(target, propertyKey, value, receiver)
Parameters
target
- : The target object on which to set the property.
propertyKey
- : The name of the property to set.
value
- : The value to set.
receiver
optional- : The value of
this
provided for the call to the setter forpropertyKey
ontarget
. If provided andtarget
does not have a setter forpropertyKey
, the property will be set onreceiver
instead.
- : The value of
Return value
A Boolean
indicating whether or not setting the property was successful.
Exceptions
A TypeError
, if target
is not an
Object
.
Description
The Reflect.set
method allows you to set a property on an object. It does
property assignment and is like the
property accessor syntax as a function.