An execution context and execution context stack
Execution Context: Preparing some javascript code execution
issue a: js engine encountered what piece of code will do "preparatory work it"?
Global code, the function code, the eval Code: executable code Type
Three concepts execution context: variable object, scope chain, the this
Question two: What preparation is?
Preparatory work is the execution context, to enhance the function declarations, variable declarations upgrade
Execution context stack
Simulation execution context stack, ECStack = [];
only when the end of the entire application, the ECS will be the case, so there is always the bottom ECStack globalContext, ECStask = [globalContex];
function f1 (){
console.log('fun1');
}
function f2 (){
f1 ();
}
f2();
//伪代码
ECStask.push(f2Context);
ECStask.push(f1Context);
ECStask.pop(f1Context);
ECStask.pop(f2Context);
Question three: the context of the execution stack closure is so stored