Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is Reflect.set working as intended? #82

Open
jfparadis opened this issue Oct 7, 2019 · 0 comments
Open

Is Reflect.set working as intended? #82

jfparadis opened this issue Oct 7, 2019 · 0 comments

Comments

@jfparadis
Copy link

@tvcutsem, would you have a reference on the rationale for the behavior of Reflect.set? I can understand the specs, but it's nonetheless surprising. Thanks in advance!

Reflect.set is quite intuitive.

g = { foo: 'A' }; e = { foo: 'B' }; 
console.log(Reflect.get(e, 'foo', g)); // 'B' <= as we expect, value came from "e"

However, Reflect.set is surprising.

Reflect.set(e, 'foo', 'X', g); 
console.log(g.foo, e.foo) // 'X', 'B' <= surprise, data property was set on "g"

This also seems to confuse others:

I guess it's just confusing that Reflect.get reads from the target, while Reflect.set writes to the receiver.

https://stackoverflow.com/questions/47992070/reflect-set-not-working-as-intended

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant