Test (v2)

Revision 2 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
For loop
const arr = []
for(let i = 0; i < 10000; i++) {
	arr.push(i + 1)
}
ready
Array from
const arr = Array.from({length: 10000}, (_, i) => i + 1)


ready
Array fill
const arr = Array(10000).fill(null).map((_, i) => i + 1)
ready
Array keys
const arr = [...Array(10000).keys()]
ready
Array keys array from
const arr = Array.from(Array(10000).keys())
ready
Array from Array
const arr = Array.from(Array(10000), (_, i) => i + 1) 
ready
Array fill without map
const arr = Array(10000).fill((_, i) => i + 1)
ready
Array from map
const arr = Array.from({length: 10000}).map((_, i) => i + 1)
ready
Array from map 2
const arr = Array.from(Array(10000)).map((_, i) => i + 1)
ready
for loop index
const arr = [];
for(let i = 0; i < 10000; i++) {
	arr[i] = i + 1
}
ready

Revisions

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