Skip to content

reduceRight

Subhajit Sahu edited this page Feb 2, 2021 · 18 revisions

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

Alternatives: reduce, reduceRight.
Similar: map, filter, reject, 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