es.array.reduce.js 739 B

12345678910111213141516
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var $reduce = require('../internals/array-reduce').left;
  4. var arrayMethodIsStrict = require('../internals/array-method-is-strict');
  5. var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
  6. var STRICT_METHOD = arrayMethodIsStrict('reduce');
  7. var USES_TO_LENGTH = arrayMethodUsesToLength('reduce', { 1: 0 });
  8. // `Array.prototype.reduce` method
  9. // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
  10. $({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH }, {
  11. reduce: function reduce(callbackfn /* , initialValue */) {
  12. return $reduce(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);
  13. }
  14. });