6 function reduceRight(arr, fn, initVal) {
7 // check for args.length since initVal might be "undefined" see #gh-57
8 var hasInit = arguments.length > 2;
10 if (arr == null || !arr.length) {
14 throw new Error('reduce of empty array with no initial value');
18 var i = arr.length, result = initVal, value;
20 // we iterate over sparse items since there is no way to make it
21 // work properly on IE 7-8. see #64
27 result = fn(result, value, i, arr);
33 module.exports = reduceRight;