-
Notifications
You must be signed in to change notification settings - Fork 3
reduce
Subhajit Sahu edited this page Jun 11, 2020
·
13 revisions
Reduces values to a single value. 🏃 [:vhs:] 📦 🌔 📒
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