for loop comparison

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
traditional for
const arr = new Array(1e7).fill(0);
for (let i = 0, il = arr.length; i < il; i++) {
	
}
ready
for...of
const arr = new Array(1e7).fill(0);
for (let value of arr) {
	
}
ready
for...in
const arr = new Array(1e7).fill(0);
for (let key in arr) {
	
}
ready
.forEach
const arr = new Array(1e7).fill(0);
arr.forEach(function(){});
ready

Revisions

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