23
rated 0 times
[
27]
[
4]
/ answers: 1 / hits: 186685
/ 14 Years ago, tue, september 21, 2010, 12:00:00
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 under SpiderMonkey.
Thinking very inside-the-box I have been using:
var count = 0;
for(var i = 0; i < array.length; i++)
{
count = count + array[i];
}
I'm sure there is a better way then straight iteration.
More From » arrays