let a = 1;
function outer() {
console.log(a);
function inner() {
console.log(a);
var a = 3;
}
inner();
console.log(a);
}
outer();
why 'a' is undefined in the inner function above? shouldn't it be able to find a = 1 in the first line through scope chain?
inner function is inside outer function, and outer function is inside the global scope.