0
点赞
收藏
分享

微信扫一扫

Hack_Kid

一世独秀 2023-11-16 阅读 35
Array.prototype.myReduce = function (callback, init) {
  if (!Array.isArray(this)) throw new TypeError('my reduce only use in Array');
  if (typeof callback !== 'function') throw new TypeError('callback is not a Function');
  let result = this[0];
  let _this = [...this];
  if (init !== undefined) {
    result = init;
    _this = [init, ...this];
  }
  for (let i = 1; i < _this.length; i++) {
    result = callback(result, _this[i]);
  }
  return result;
};
举报

相关推荐

hack语言

物理hack

css hack

遥控器hack

hack遥控器

CSS hack技术

hack the box lame靶机

hack the box jerry靶机

0 条评论