Quick Tip: JavaScript Hoisting Explained

Jeffrey Way writing for Net Tuts:

Variable Declarations are Hoisted

Within its current scope, regardless of where a variable is declared, it will be, behind the scenes, hoisted to the top. However, only the declaration will be hoisted. If the variable is also initialized, the current value, at the top of the scope, will initially be set to undefined.

A good tip for the flux of new developers coming over to the JavaScript world. Hoisting is definitely a gotcha I remember running into. Read the whole thing for examples, it’s a good explanation.