Feel that call and apply are inherited, can point to a different function to pass arguments, invoke methods, see the Code
Function F1 () {
this.p= "1---";
This. A=function (ARG) {
Alert (THIS.P+ARG)
}
}
function F2 () {
this.p= "2---";
This. B=function (ARG) {
Alert (THIS.P+ARG)
}
}
instantiate the function of F1
var fn1=new f1 ();
var fn2=new f2 ();
call the A method, use apply to point to the instantiated object fn1, pass the parameters
Fn1. A.apply (fn1,["This is apply (FN1)]) //1---1
call the A method, use apply to point to the instantiated object fn2, pass the parameters
Fn1. A.apply (fn2,["This is apply (FN2)]) //2---1
Call the B method to point to Fn1, the instantiated object, and pass the parameters
Fn2. B.call (FN1, "This was call (FN1)")
Call the B method to point to Fn2, the instantiated object, and pass the parameters
Fn2. B.call (FN2, "This was call (FN2)")
Use of call and apply