For loop test (v2)

Revision 2 of this benchmark created on


Setup

const LENGTH = 1_000_000;
const target = Array.from({length: LENGTH}, () => Math.floor(Math.random() * LENGTH));

Test runner

Ready to run.

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

Revisions

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