For loop variants

Benchmark created on


Setup

const DATA = [...Array(1e6).keys()]

Test runner

Ready to run.

Testing in
TestOps/sec
forEach
DATA.forEach((num) => {let result = num*2})
ready
for
for (let i=0; i < DATA.length; i++) { let result = DATA[i]*2 }
ready
for of
for (const num of DATA) { let result = num*2 }
ready

Revisions

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