Skip to content

reduceRight

Subhajit Sahu edited this page Jun 20, 2020 · 18 revisions

Reduces values from right, to a single value. 🏃 📼 📦 🌔 📒

Alternatives: reduce, reduceRight.
Similar: map, filter, reduce, accumulate.

array.reduceRight(x, fr, [acc]);
// x:   an array
// fr:  reduce function (acc, v, i, x)
// acc: initial value
const array = require('extra-array');

var x = [1, 2, 3, 4];
array.reduceRight(x, (acc, v) => acc+v);
// 10

array.reduceRight(x, (acc, v) => acc+v, 100);
// 110

references

Clone this wiki locally