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

multiple variable declarations in the same scope #17

Open
masuhar opened this issue May 21, 2018 · 0 comments
Open

multiple variable declarations in the same scope #17

masuhar opened this issue May 21, 2018 · 0 comments

Comments

@masuhar
Copy link
Contributor

masuhar commented May 21, 2018

With the program:

var x = { value: 1, next: null};
var x = { value: 2, next: x};

The object pointed by x at the end of line 2 has null in the next field. When you remove "var" at the begging of line 2, the next field will point to an object with value 1. According to the semantics of JavaScript, "redeclaration of a variable will not lose its value" (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var). So the code without var on the second line should behave similar to the one with var.

image

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