Skip to content
Subhajit Sahu edited this page Jun 11, 2020 · 13 revisions

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

Similar: map, reduce, filter, filterAt, reject, rejectAt.

object.reduce(x, fn, [acc]);
// x:   an object
// fn:  reduce function (acc, v, k, x)
// acc: initial value
const object = require('extra-object');

var x = {a: 1, b: 2, c: 3, d: 4};
object.reduce(x, (acc, v) => acc+v);
// 10

object.reduce(x, (acc, v) => acc+v, 100);
// 110

references

Clone this wiki locally