different ways to loop

Benchmark created on


Setup

var arr = [...new Array(10000)].map(() => Math.random());

Test runner

Ready to run.

Testing in
TestOps/sec
for
let sum = 0;
for (let i = 0; i < arr.length; i++) {
	sum += arr[i];
}
ready
for-of
let sum = 0;
for (const x of arr) {
	sum += x;
}
ready

Revisions

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