javascript中的apply

// 与call不同的是,后面的参数是一个数组
Function.prototype.apply = function (cotext, args) {
  context = context ? context : window;
  context.fn = this;
  if(!args) return context.fn;
  let r = eval('context.fn('+args+')');
  delete context.fn;
  return r;
}

你可能感兴趣的:(javascript中的apply)