-
Notifications
You must be signed in to change notification settings - Fork 1
reduce
Subhajit Sahu edited this page Dec 5, 2022
·
16 revisions
Reduce values of set to a single value.
function reduce(x, fr, acc?)
// x: a map
// fr: reduce function (acc, v, k, x)
// acc: initial value
const map = require('extra-map');
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