//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

 

相关文章:

  • 2021-07-20
  • 2021-12-25
  • 2021-08-16
  • 2022-01-31
  • 2022-12-23
  • 2021-08-23
  • 2021-12-25
  • 2021-08-02
猜你喜欢
  • 2021-08-11
  • 2021-08-25
  • 2022-02-08
  • 2021-07-30
  • 2022-12-23
  • 2021-10-18
  • 2022-12-23
相关资源
相似解决方案