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 hois
Variable declarations are hoisted, the assignments are not.
By using var myvaranywhere 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.