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