Can you explain why these two are producing different output
var x = 5; console.log(x); console.log(y);
var x = 5; console.log(y); console.log(x);
Both of the code are giving reference error as expected. But the first program printing
5 then giving
reference error, as it’s not able to find variable
y in it’s scope.
But the second code is giving reference error then terminating the code. Why the