Loops

Benchmark created on


Setup

const arr = Array.from({ length: 20000}, (v, i) => i)

Test runner

Ready to run.

Testing in
TestOps/sec
For each
const newArr = []

arr.forEach(id => {
	newArr.push(id)
})
ready
For
const newArr = []

for(let i = 0, id; (id = arr[i]); i++) {
	newArr.push(id)
}
ready
For of
const newArr = []

for(const id of arr) {
	newArr.push(id)
}
ready

Revisions

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