MDN # var:
... JavaScript, .
, x f ( ), ( var) x redeclaration ( , f, ).
In the second example, it is xdeclared inside a function f. Therefore, when viewing the values xfor the transition to, logwe use this xinside f(and not external), and since we obviously did not give it a value (initializing it), its value will be undefined.
source
share