Reduce vs For loop

Benchmark created on


Setup

const a = [1,2,3,4,5,6,7,8,9,10];

Test runner

Ready to run.

Testing in
TestOps/sec
Reduce

const b = a.reduce((i,j)=> i+j,0);
console.log(b)
ready
For-loop
let sum = 0;
for(let i=0;i < a.length;i = i+1) {
	
	sum = sum + a[i];
}

console.log(sum)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.