预编译笔记

2019-06-14  本文已影响0人  门门_
function test(a){
          console.log(a);

        var a=1;
              console.log(a);
        function a(){}
            console.log(a);

        var b=function(){}
              console.log(b);
        function d(){}
}

test(2);

AO activation object (活跃对象,函数上下文)
AO={
1.寻找函数的形参和变量声明
a: undefined
b:undefined
2.将实参的参数值赋值给形参
a:undefined ==> 2
b:undefined
3.寻找函数体的函数声明,赋值函数体
a:undefined ==> 2==> function a(){}
b:undefined
d:function d(){}
}
4.执行
a:undefined ==> 2 ==> function a(){} ==> 1]
b:undefined ==> function(){}
d: function d(){}



var a = 1;
function a(){
console.log(2);
}
console.log(a);
===>  1

GO global object (全局上下文)
GO = {
1.寻找变量声明
a:undefined
2.寻找函数声明
a:undefined => function a(){}
3.执行
a:undefined => function a(){} => 1
}

总结:GO == window

上一篇 下一篇

猜你喜欢

热点阅读