When running the following block of code, FF and Chrome output typeof(hiya) = string
while IE7/8 output typeof(hiya) = undefined
.
&
What you encountered is due to:
var
being a statementSo what happens is that JavaScript will execute the var
statement before before anything else, but it will not evaluate the assignment expression, therefor hiya
will default to the value of undefined
.
As Raynos already stated IE will execute each scripts on its own, therefore the behavior described above, will results in hiya
being undefined.