function a(){
var x,y,a,b;
var a=2;
var b=2;
if (true) {
var a,b;
b=1;
a = 1;
}
alert(a)
}
a();
Why the result is not 2? I wonder why redeclaration of a and b in if condition does not create a new variable a and b? Is there any rule I can follow?