-
Notifications
You must be signed in to change notification settings - Fork 3
reduce
Subhajit Sahu edited this page Dec 8, 2022
·
13 revisions
Reduce values to a single value.
function reduce(x, fr, acc?)
// x: an object
// fr: 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