JavaScript uses lexical scoping, meaning that functions are executed using the variable scope that was in effect when they were defined, not when they are invoked.
Source Code
let a = 'global';
function outer() {
let b = 'outer';
function inner() {
let c = 'inner';
console.log(c); // inner
console.log(b); // outer
console.log(a); // global
}
inner();
}
outer();