|
лет назад: 2 | |
---|---|---|
.. | ||
example | лет назад: 2 | |
test | лет назад: 2 | |
.travis.yml | лет назад: 2 | |
LICENSE | лет назад: 2 | |
index.js | лет назад: 2 | |
package.json | лет назад: 2 | |
readme.markdown | лет назад: 2 |
[].reduce()
for old browsers
var reduce = require('array-reduce');
var xs = [ 1, 2, 3, 4 ];
var sum = reduce(xs, function (acc, x) { return acc + x }, 0);
console.log(sum);
output:
10
var reduce = require('array-reduce')
Create a result res
by folding acc = f(acc, xs[i], i)
over each element in
the array xs
at element i
. If init
is given, the first acc
value is
init
, otherwise xs[0]
is used.
With npm do:
npm install array-reduce
MIT