A.call (B, x, y): in fact, can be seen as a function of A to B is placed in operation, x and y are the parameters A method.
function fn1(a,b){ return a + b; } function fn2( ){ } was val = fn1 (5.2 ); was VAL2 = fn1.call (fn2,5,2 ); console.log(val);//7 console.log(val2);//7
function fn1(){ this.name = "zhangsan"; this.myTxt = function (txt){ console.log("hello",txt); }; } function Person(){ fn1.call(this); } where p = new Person (); console.log(p.name); p.myTxt("world");
"Chained" to borrow: