用js实现call方法

Function.prototype.call2 = function (context, ...args) {
  var context = context || window;
  //改变this指向
  context.__proto__.fn = this;
  //调用函数
  var res = context.fn(...args);
  //删除多余属性
  delete context.__proto__.fn;
  return res;
}

原文地址:https://www.cnblogs.com/wangsai-666/p/12038230.html