I\'ve been reading about JavaScript hoisting sometime back.
JavaScript Scoping and Hoisting by Ben Cherry Two words about “hoisting” by Dmitry Soshnikov
Only variable declaration is eagerly evaluated. The variable assignment in your first case (in the if block) occurs only upon entering the if block.
if
The variable you only declare, but not assign any value to, has the value of undefined (which coerces to false).
undefined
false