for or forEach

Benchmark created on


Setup

const arr = new Array(1000)

for (let i=0; i < arr.length; i++) {
	arr[i] = i + 1;
}

Test runner

Ready to run.

Testing in
TestOps/sec
For
for (let i = 0; i < arr.length; i++) {
    arr[i] += 1;
}
ready
forEach
arr.forEach((element, index) => {
    arr[index] += 1;
});
ready

Revisions

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