For vs Reduce

Benchmark created on


Setup

var arr = new Array(10000).fill(1)

Test runner

Ready to run.

Testing in
TestOps/sec
For
let sum
for (let i = 0; i < arr.length; i++) {
	sum += arr[i]
}
ready
Reduce
const sum = arr.reduce((acc, val) => {
	acc += val;
	return acc
}, 0)
ready

Revisions

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