When the x function is executed, the browser displays an error such as:
Uncaught ReferenceError: z is not defined
at x (<anonymous>:1:27)
As expected, there is no error, and because we did not define a value for z, the displayed value is undefined. Note that the value undefined, is not the same as undeclared -- the variable exists (is declared), but has no value (undefined).
You would think that the log statement would fail, but the value displayed is undefined because the variable declaration is "hoisted" to the top of the function, just like the previous example.
Does not display 1, because even though the variable declaration is hoisted to the top of the function, the initialization still occurs after the log statement is executed.