The execution environment in JavaScript defines the other data that a variable or function has access to, determines its behavior, and each execution environment has a variable object associated with it, and the variables and functions defined in the environment are stored in the object.
The global execution environment is one of the outermost execution environments. The global execution environment is considered a Window object, and all global variables and functions are created as properties and methods of the Window object. After all the code in an execution environment is executed, the environment is destroyed, and all the variables and function definitions stored therein are also sold.
Each function has its own execution environment, and when the execution flow enters a function, the environment of the function is pushed into an environment stack, and after the function is executed, the stack ejects its environment and returns control to the previous execution environment. The execution flow in the ECMAScript program is controlled by this convenient mechanism.
When code executes in an environment, a scope chain of variable objects is created, and the scope chain is an orderly access to all the variables and functions that the execution environment has access to. The most front-end of a scope chain is always a variable object in the environment in which the current execution code resides. If the environment is a function, its active object is used as a variable object, and the active object initially contains only one variable, the arguments object, and the next variable object in the scope is the containing environment of the variable object.
Identifier parsing is the process of searching identifiers at the first level along the scope chain.