The first code example given appears to be identical to one on Ben Cherry's adequately good site. This goes into more detail on the way scoping works in JavaScript (primarily - it's function-level, not block-level), and ends with the following statement, attributed directly to the ECMAScript Standard:
If the variable statement occurs inside a FunctionDeclaration, the variables
are defined with function-local scope in that function, as described
in section 10.1.3. Otherwise, they are defined with global scope (that
is, they are created as members of the global object, as described in
section 10.1.3) using property attributes.
...
A Block does not
define a new execution scope. Only Program and FunctionDeclaration
produce a new scope.
This hopefully explains why the code you include works the way it does - there is no "way the code looks after hoisting", there's just a simple (and, common) misunderstanding about how scope works in JavaScript.