bind函数

Function.prototype.myBind = function (context, ...args1) {
  if (typeof this !== "function") throw new TypeError("类型错误");
  let fun = this;

  return function F (...args2) {
    if (this instanceof F) {
      return new F(...args2);
    }
    return fun.apply(context, args1.concat(args2));
  }
}