手写apply

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

Function.prototype.myApply = function(content,arr){
  console.log('myApply');
  let _this = this;
  let sy = Symbol();
  content[sy] = _this;
  return content[sy](...arr);
}

function add(c,d,e){
  console.log(this.a + this.b + c + d + e);
}
add.myApply(obj,[2,4,1]);

原文地址:https://www.cnblogs.com/jayking1314/p/14874280.html