All the loops

Benchmark created on


Setup

let list = [];

for (let index = 0; index < 10000; index++) list[index] = index;

function nextNumber(number) {
	return number++;
}

Test runner

Ready to run.

Testing in
TestOps/sec
for...
for (let index = 0; index < list.length; index++) {
	nextNumber(list[index]);
}
ready
...forEach
list.forEach(nextNumber);
ready
for... in...
 for (let index in list) {
    nextNumber(list[index]);
 }
ready
for... of...
 for (let item of list) {
    nextNumber(item);
 }
ready

Revisions

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