(1)bind使用方法
myFun(fm,t){
console.log(`名字${this.name},年龄${this.age},来自${fm},去哪${t}`)
}
let db = {
name: '地球',
age: '500'
}
let tmp = myFun.bind(db,'新生','毁灭')
tmp()
(2)手动实现bind
Function.prototye.testBind = function(){
let _this = this //this指向那个调用的函数
let bindThis = [].splice.apply(arguments,[0,1]) //保存要绑定的this,这个返回的是数组
let argu = arguments //保存参数
return function(){
_this.apply(bindThis[0],argu) //
}
}