You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
With the program:
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.
The text was updated successfully, but these errors were encountered: