Loop

Benchmark created on


Setup

const array = new Array(10000).fill(0);

Test runner

Ready to run.

Testing in
TestOps/sec
for
  for (let i = 0; i < array.length; i++) {
    const element = array[i];
  }
ready
for...of
  for (const element of array) {
    // do nothing
  }
ready
forEach
 array.forEach(element => {
    // do nothing
  });
ready
while
  let i = 0;
  while (i < array.length) {
    const element = array[i];
    i++;
  }
ready

Revisions

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