Loops

Benchmark created on


Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
Map
const newArr = arr.map(elem => elem)
ready
For of
const newArr = []

for(const elem of arr) {
	newArr.push(elem)
}
ready
For
const newArr = []

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

for(let i = 0; i < arr.length; i++){
	newArr.push(arr[i])
}
ready

Revisions

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