The book says:
No matter where a function is invoked from, or even how it is invoked, its lexical scope is only defined by where the function was declared.
And here is an example that proves it:
let a = "1";
function test() {
console.log(a);
}
function newZone() {
let a = "2";
test();
}
newZone();
But in this case the Lexical Scope is defined at the moment the function is called:
let a = 1;
function test() {
console.log(a, b);
}
test(); // error
let b = 10;
test(); // 1,10
Help me understand when Lexical Scope is defined