首页 > 移动平台 > 详细

手写apply

时间:2021-06-11 12:16:14      阅读:23      评论:0      收藏:0      [点我收藏+]

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]);

手写apply

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!