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
See function four on What is the scope of variables in JavaScript?
four
As of 2012, there's no block-level scope in JavaScript. So your first version is fine: the variables are defined in the scope outside the if block.
if