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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…