Function.prototype.myBind = function(content,...arg){
  let _this = this;
  return function(...arguments){
    _this.call(content,...arg.concat(arguments));
  }
}

let obj = {
  a:1,
  b:2
}

var a = 1, b = 1;

function add(c,d){
  console.log(this.a+this.b+c+d);
}
//add();
let aFn = add.myBind(obj,1);
aFn(2);

posted on 2021-06-11 10:33  皮杰克  阅读(36)  评论(0编辑  收藏  举报