I am testing this on Google Chrome:
function test(){
d = 2;
}
function test2(){
test();
document.write(d);
}
test2();
The variable d in function test
supposed to be local so I cannot access it in function test2
, can someone explain why this works?
Edit:
This is not duplicate, as I cannot find anywhere in the correct answer of the original question that using a variable without var makes it global, it is mentioned implicitly as 'horror of implicit globals`