//  the class

function cal()

{

    this.add = function (x, y)

    {

       return x + y;

    }

}

//  the object to apply

var ins_tmp = new cal();

 

//  the function

function b()

{

    //  notice: without the apply method, what is 'this' below?

    alert(this.add(arguments[0], arguments[1]));

}

 

//  arguments(parameters).

var args = new Array();

 

args[0] = 1;

args[1] = 3;

 

//  try directly call the function 'b()'

//  notice the error message in the error dialog box.

b.apply(ins_tmp, args);

 

相关文章:

  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2021-07-12
  • 2021-09-05
  • 2021-08-23
猜你喜欢
  • 2021-06-19
  • 2021-12-10
  • 2021-06-02
  • 2021-07-14
  • 2021-12-31
  • 2021-09-05
  • 2022-02-09
相关资源
相似解决方案