What is the fastest way to sum up an array in JavaScript? A quick search turns over a few different methods, but I would like a native solution if possible. This will run un
You should be able to use reduce.
reduce
var sum = array.reduce(function(pv, cv) { return pv + cv; }, 0);
Source
And with arrow functions introduced in ES6, it's even simpler:
sum = array.reduce((pv, cv) => pv + cv, 0);