operating Environment : the environment in which JavaScript code snippets are executed (can be understood as scopes in C/s + +)"Personal understanding"
Variable Object : The first is an object that holds all the variables and functions of the current execution environment (JavaScript functions can be nested, C + + is not as if (the new version seems to be possible))
Correspondence Relationship : Each execution environment has an associated variable object
scope chain : chain, linked list.
Function: Ensures an orderly access to all variables and functions that the execution environment has access to (what ghost, the language of the test?) )
Current variable object → variable object containing environment → variable object containing environment ... → Global execution object's variable object
Note: There is no concept of block-level scope in JavaScript
if (true) { var color = ' red ';} Console.log (color);
is correct in JavaScript and is incorrect in C + +
The following code is problematic
function Outfun () { var color1 = ' yellow '; function Innerfun () { var color2 = ' green '; } Console.log (COLOR2); // not correct }
Why is it wrong? JS is not a block-level scope, yes there is no block-level scope. But there is an execution environment (scope)
The execution environment of the COLOR2 here is valid in Innerfun (the scope of C + + is understood)
JavaScript runtime environment and scope chain