es.array.reduce-right.js 895 B

1234567891011121314151617
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var $reduceRight = require('../internals/array-reduce').right;
  4. var arrayMethodIsStrict = require('../internals/array-method-is-strict');
  5. var arrayMethodUsesToLength = require('../internals/array-method-uses-to-length');
  6. var STRICT_METHOD = arrayMethodIsStrict('reduceRight');
  7. // For preventing possible almost infinite loop in non-standard implementations, test the forward version of the method
  8. var USES_TO_LENGTH = arrayMethodUsesToLength('reduce', { 1: 0 });
  9. // `Array.prototype.reduceRight` method
  10. // https://tc39.github.io/ecma262/#sec-array.prototype.reduceright
  11. $({ target: 'Array', proto: true, forced: !STRICT_METHOD || !USES_TO_LENGTH }, {
  12. reduceRight: function reduceRight(callbackfn /* , initialValue */) {
  13. return $reduceRight(this, callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined);
  14. }
  15. });