In this example, I know that it's going to print undefined.
var bar = typeof foo;
var foo = function() {
  console.log('abcd');
}
foo();
console.log(bar); // -> undefined
So I understand that when the variables are hoisted, bar remains above foo, but foo gets executed, so shouldn't the interpreter know what foo is?
Note: I'm trying to understand how the interpreter works. My question isn't about how to fix the above snippet.
 
     
    