Scope chain, closure

AO function will produce a moment before execution

AO execution order:

1. The variable parameter and affirmed

2. The parameter assigned to the arguments

3. Look for a function declaration

4. execution of the function

After the completion of the implementation will be destroyed

function test()

{

a=1;

function a(){

}

There is 2;

return a;

}

console.log(test());


AO = {a: undefined -> a () -> 1 (execution) -> 2 (execution)}

 

The scope chain

[[Scope]] is a storage scope chain

 

 

Guess you like

Origin www.cnblogs.com/yiyi24/p/11887819.html