While I was reading about Javascript hoisting, I tried the following. I am not sure why the first one and second one output differently. Thanks in advance. (I am not even su
The declaration of thee local variable in the if block in the second example is hoisted to the entire function.
if
Thus, me in the function always refers to the local variable, not the global.
me
However, the value of the variable is not hoisted, so it's always undefined and the if is never entered.
undefined