function foo(data){
console.log(this,data); //this -> window
}
var obj = {name:'124'}
foo.call(obj,12) //this->obj
foo.apply(obj, [12]) //this->obj
foo.bind(obj,33)() //foo.bind(obj,33)返回函数
bind应用场景:
setTimeout(function(){
console.log(this)
},bind(obj),1000) // this->obj
网友评论