Variable Not Hoisted
In Javascript variables are hoisted to the top of the scope they are declared within. However in the following code it seems that the variable myvar is not hoisted. &l
Solution 1:
Variable declarations are hoisted, the assignments are not.
By using var myvar
anywhere in the function you create a locally scoped variable myvar
, but if you follow it with = something
then the assignment will take place in normal code order.
Post a Comment for "Variable Not Hoisted"