I am not understanding this - how can a var
that's defined within an if
condition be used outside of that condition?
Example JS:
if (1===2) {
var myVar = "I live in brackets";
}
$("#debug").append("myVar = " + myVar);
$("#debug").append("but I'm about to throw a 'not defined' exception right... now " + firstAppearanceVar);
Renders: myVar = I live in brackets
Isn't myVar
's scope only inside of that if (1===2)
condition?