Why does z() execution context not override global x variable?
var x = 10;
function z(){
var x = x = 20;
}
z();
console.log(x); // why is 10 printed? Shouldn’t it be 20.
var a = b = c = 0;
It means b and c are being declared as globals, not locals as intended.
For example -
var y = 10;
function z(){
var x = y = 20; // global y is overridden
}
z();
console.log(y); // value is 20
Going by above logic, x = x = 20 in z() means x is global which overrides the local x variable but still global value of x is 10