es.array.reduce.js 884 B

1234567891011121314151617181920
  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 CHROME_VERSION = require('../internals/engine-v8-version');
  6. var IS_NODE = require('../internals/engine-is-node');
  7. var STRICT_METHOD = arrayMethodIsStrict('reduce');
  8. // Chrome 80-82 has a critical bug
  9. // https://bugs.chromium.org/p/chromium/issues/detail?id=1049982
  10. var CHROME_BUG = !IS_NODE && CHROME_VERSION > 79 && CHROME_VERSION < 83;
  11. // `Array.prototype.reduce` method
  12. // https://tc39.es/ecma262/#sec-array.prototype.reduce
  13. $({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, {
  14. reduce: function reduce(callbackfn /* , initialValue */) {
  15. var length = arguments.length;
  16. return $reduce(this, callbackfn, length, length > 1 ? arguments[1] : undefined);
  17. }
  18. });