首页 > 技术文章 > call、apply、bind

gamedaybyday 2016-11-13 23:44 原文

 

三者都是用来改变函数的this对象的指向的

fun.call(this,a,b);   //相当于 this.fun(a,b)

fun.apply(this,[a,b]); //相当于 this.fun(a,b);

fun.bind(this);   // 返回 this.fun 

fun.bind(this)();  //相当于 this.fun();

 

推荐阅读