Call, Apply is a method of Function.prototype, which is implemented internally by the JavaScript engine because it belongs to Function.prototype, so each function object instance, that is, each method has a call , apply property. As a property of the method, the use of them is of course a method. These two methods are easy to confuse, because they work the same way, but only in different ways.
The same thing: they all have the same effect.
Different points: Their parameters are different
Call (THIS,ARG1,ARG2,ARG3);
Apply (this,arguments);
Apply has the same effect as call.
Call, the role of apply is to borrow someone else's way to invoke, just like calling their own.
function Add (b) { alert (a+b); } function Sub (b) { alert (a-b); } Add.call (Sub,3,1); Add.apply (sub,[3,1]);
Their differences are written in the parameters of the call, respectively. The argument to apply is an array
The role and difference of call () and apply ()