Simple learning apply, call and bind the

They can be changed this point

apply and call Simply put, all the same thing, but with different parameters

obj.Fun.call(nd);   
obj.Fun.apply(nd); 

Wherein a plurality of call parameters can be transferred, apply only pass two parameters

obj.Fun.call(nd,xx,xx);   
obj.Fun.apply(nd,[xx,xx]); 

bind returns a new function, it must call will be executed

obj.Fun.bind(nd)();
obj.Fun.bind(nd,xx,xx)();

 

Guess you like

Origin www.cnblogs.com/lipu12281/p/12017272.html
Recommended