It seems unlikely that I found some kind of glaring cross-browser bug. But according to the documentations Reflect.set
is supposed to use the 4th parameter as the thisArg (for example if the set variable is a setter). The first argument is the object the value is to be set on, yet whenever I supply any object as the 4th argument, the value gets set on that instead of the target object.
var target = new Object;
var thisArg = new Object;
Reflect.set(target, 'variable', 52, thisArg);
target.variable == undefined
thisArg.variable == 52
Any explanation?
The first argument is the object the value is to be set on
Not exactly. The first argument is the object whose setters are invoked (including those on the object's prototype chain).
whenever I supply any object as the 4th argument, the value gets set on that instead of the target object.
Yes. Because the property always gets set on the receiver. It's just that the argument is optional because it's usually the same as the target, and therefore defaults to the first argument when not supplied.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With