I was wondering, why the alert result is different after commenting out this line function a() {}
? What is the relationship between function a() and variable a?
Snippet 1:
var a = 1;
function b() {
a = 10;
return;
//function a() {}
}
b();
alert(a); // 10
Snippet 2:
var a = 1;
function b() {
a = 10;
return;
function a() {}
}
b();
alert(a); // 1