Lexical environments contain an environment record in which the variables are stored and a reference to their parent environment.
Lexical environments build a tree structure.
function b(){
function a(){
return 0;
}
return 0;
}
- In this case function a is
lexically
inside the b function.
In JavaScript, without this
keyword, lexical scope is important where data and variable is defined.
- Dynamic scope: where the function is called.