Fill VS for loop VS anything else

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
For loop
let array = Array(100)
for (i = 0; i < 100; i++) {
	array[i] = 50
}
console.log(array)
ready
Fill
let array = Array(100)
array.fill(50)
console.log(array)
ready
Something else
let array = Array()
for (i = 0; i < 100; i++) {
	array.push(50)
}
console.log(array)
ready
Still something else
let array = Array()
for (i = 0; i < 25; i++) {
	array.push(50, 50, 50, 50)
}
console.log(array)
ready

Revisions

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