Is defining JavaScript variables inside if-statements correct?
if(a==1){ var b = 1; } else { var b = 0; }
I know the code above will wo
Putting a var inside an if statement is not against "the rules" of the language, but it means that, because of var hoisting, that var will be defined regardless of whether the if statement's condition is satisfied.