封装函数 f,使 fthis 指向指定的对象

function bindThis(f, oTarget) {
return f.bind(oTarget); //返回了传入的函数 加括号传参调用
}

bindThis(function(a, b){
return this.test + a + b
},{test: 1})(2, 3)

// const abc = bindThis(function(a, b){
// return this.test + a + b
// },{test: 1})(2, 3)
// console.log(abc); //6