This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
multiple assignement with objects #90
Comments
I will try to explain to the best of my knowledge. I reserve the right to be completely wrong ;D var foo = {n: 1}; --> this is placing content in some point A in memory, "foo" is the address to point A. foo = {n: 2}; --> this is placing content in some point B in memory, "foo" has a new address, now to point B. Note that "bar" is unaltered, it stills point to content in address A. Then: I do not think that is a strange behavior to js, just that pointers are somewhat counterintuitive. |
That would be indeed a very strange behavior — it's simply that the member access operator (the dot [
By the way, you couldn't do this in two lines without my fictional When you have pointers (e.g. In some languages, like C++, you can even do this: |
I agree with your analysis, but I believe it could have it's place in the examples of wtfjs ! |
PR is welcome. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
foo.x == undefined, but bar.x == foo
The text was updated successfully, but these errors were encountered: