bind在ie6,7,8中不执行
call和apply是立即执行函数,bind利用柯里化函数思想,预先把需要处理的函数/改变的this/传递的实参等信息存储在闭包中,后期到达条件(事件触发/定时器),先指向返回的匿名函数,在执行匿名函数的过程中,再去改变this等=》this和参数的预处理
- 考察call方法
var name = '珠峰培训';
function A(x,y){
var res=x+y;
console.log(res,this.name);
}
function B(x,y){
var res=x-y;
console.log(res,this.name);
}
B.call(A,40,30);
B.call.call.call(A,20,10);
Function.prototype.call(A,60,50);
Function.prototype.call.call.call(A,80,70);
2.阿里原题
bind源码仿写
1.