GT2/Ejectable/node_modules/array-reduce
Ren Juan 06c1a5835d set clean start from expo 4.10 2021-08-16 00:14:59 +00:00
..
example set clean start from expo 4.10 2021-08-16 00:14:59 +00:00
test set clean start from expo 4.10 2021-08-16 00:14:59 +00:00
.travis.yml set clean start from expo 4.10 2021-08-16 00:14:59 +00:00
LICENSE set clean start from expo 4.10 2021-08-16 00:14:59 +00:00
index.js set clean start from expo 4.10 2021-08-16 00:14:59 +00:00
package.json set clean start from expo 4.10 2021-08-16 00:14:59 +00:00
readme.markdown set clean start from expo 4.10 2021-08-16 00:14:59 +00:00

readme.markdown

array-reduce

[].reduce() for old browsers

testling badge

build status

example

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

methods

var reduce = require('array-reduce')

var res = reduce(xs, f, init)

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.

install

With npm do:

npm install array-reduce

license

MIT