一个小函数

    <script>
    function a(b){
        //var b='hello';
        alert(b);
        function b(){
            alert(b);
        }
        b();
    }
    a(1);
    </script>

请问结果是????

词法分析

1:函数运行前一瞬间生成一个活动对象Active Object(AO);

2:分析参数:AO={b:undefined}

2.1:接收参数分析:AO:{b:1}

3:分析函数声明:AO={b:function(){alert(b)}}

4:函数执行过程:

alert(b);// a function(0{}

b();//a  functinon

因此结果是弹出两个函数。。。

我的家园
原文地址:https://www.cnblogs.com/wycfcqt/p/4135949.html