This is a very confusing behavior I came upon I cannot figure out:
var foo = 'outside';
function logIt(){
console.log(foo);
var foo = 'inside';
}
logIt();
That will yield undefined. Which is already unexplicable to me. But stranger is that this :
var foo = 'outside';
function logIt(){
console.log(foo);
}
logIt();
Will actually yield outside.
Why is this happening?