function foo(){
console.log(a);
}
function bar () {
var a = 3;
foo();
}
var a = 2;
bar();
the above code, why is the result 2? it should not be the foo () function called in the bar () function, so should you first look for an in the scope of bar (), and then look for it in the global scope?
I hope that the great gods who walk by and pass by can help solve their doubts. Thank you very much.