Call Method (Function) (JavaScript)invokes the method of an object, replacing the current object with another object. Grammar
Call ([thisobj[, arg1[, arg2[, [, ArgN]]])
parameter
thisobj
optional.
arg1, arg2, ArgN
Optional. The argument list that will be passed to the method
Note
call The method is used to invoke a method that represents another project. It allows you to change the function this object from the initial context to the  thisobj new object specified.
If the thisobj parameter is not provided, the global object is used as the thisobj.
The following code demonstrates
PagerMethod
function Add (A, B)
{Console.info (this);Console.info (A+B); } function sub (a, b) {console.info (a); }
Call
Add.call (sub,3,1);
Result output
Call
Add.call (' "HH" ', 3,1);
Add.call (3,1);
The second paragraph of the procedure
function Animal () {
THIS.name = "Animal"; This.showname = function () {Console.info (this);Console.info (this.name); }} function Cat () {this.name = "cat"; } var animal = new animal (); var cat = new Cat (); Animal.showName.call (Cat, ","); Animal.showName.call (CAT); Animal.showName.call ();
Third paragraph procedure
function Animal (name) {
THIS.name = name; This.showname = function () {console.info (' call ', this); Console.info (this.name); }} function Cat (name) {Console.info ("init", this); Animal.call (this, name); } var cat = new Cat ("Black cat"); Cat.showname (); Console.info (Cat.showname);
Call Method (Function) (JavaScript)