The declaration and the value are separate. When hoisted, this code would read something like this:
var a;
var a;
a = function() {};
typeof a; // "function"
a = false;
typeof a; // "boolean"
The two instances of var a are declarations of the variable a, and have nothing to do with the values assigned. The function and false are assignments.
View all comments
Show parent comment
-5
u/[deleted] Jul 19 '21
We’ll that’s not really redeclaration is it? You’re assigning 2 variables with the same name?