for-of with array.entries vs traiditional for

Benchmark created on


Description

compare iterating array.entries() vs traiditional for loop over array indices

Setup

const array = Array.from({length: 100000}).map(() => Math.random())

Test runner

Ready to run.

Testing in
TestOps/sec
for-of
for (const [i, value] of array.entries()) {
	globalThis.window
}
ready
traditional for loop
for (let i=0, l=array.length; i<l; i+=1) {
	globalThis.window
}
ready

Revisions

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