Jquery Call ,apply,callee

     //call
        function A() {
            name = "abc";
            this.ShowName = function (val) {
                alert(name + "," + val);
            }
        }

        function B() {
            name = "def";
        }
        var a = new A();
        var b = new B();
        a.ShowName.call(b, "123");

        //返回的是 def, 123

        //apply
        function A1(arr) {
            this.value = 105;
            if (arguments[1]) {
                if (arguments[1] < 100)
                    this.value = 88;
                else
                    this.value = arguments[0]
            }
        };
        function B1(arrt) {
            A1.apply(this, arguments);
            console.log("B1返回结果:"+this.value);
        }
        B1(66, 105);
        //返回 66;

        //callee
        function A2(x)
        {
            if (x > 5)
            {
                console.log(x);
                arguments.callee(x - 1);
            }
        }
        A2(10);
       //返回:10,9,8,7,6

 

posted @ 2013-12-09 12:18  Shikyoh  阅读(2549)  评论(3编辑  收藏  举报