Test name | Executions per second |
---|---|
reduce | 6738364.5 Ops/sec |
loop | 161457.6 Ops/sec |
loop2 | 159848.8 Ops/sec |
t = [];
for (let i=0; i < 50; i++) t.push(Math.random());
t.reduce((p,c) => p+c, 0);
(() => {
let res = 0;
for (let i=0;i<t.length;i++) res += t[i];
return res;})();
(() => {
var i, res;
for (i=res=0;i<t.length;i++) res += t[i];
return res;})();