For vs ForEach

Benchmark created on


Setup

const list = Array.from({ length: 10 }, (_, i) => i);
const run = fn => fn(list);
const noop = i => i;

Test runner

Ready to run.

Testing in
TestOps/sec
for of
run(list => {
  for (let n of list) {
    noop(n);
  }
})
ready
forEach
run(list => list.forEach(noop))
ready

Revisions

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