Skip to content
Subhajit Sahu edited this page Jun 17, 2020 · 14 revisions

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

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

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

var x = new Map([['a', 1], ['b', 2], ['c', 3], ['d', 4]]);
map.reduce(x, (acc, v) => acc+v);
// 10

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

references

Clone this wiki locally