Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array fill method vs for loop test (with map)
(version: 1)
Array fill method vs for loop performance validation
Comparing performance of:
For Loop fill vs Array Fill vs Push vs Map
Created:
3 months ago
by:
Guest
Jump to the latest result
Tests:
For Loop fill
let arrayTest = new Array(10000000); for (let i = 0; i < arrayTest.length; i++){ arrayTest[i] = 0; }
Array Fill
let arrayTest = new Array(10000000).fill(0);
Push
let arrayTest = []; for (let i = 0; i < 10000000; i++){ arrayTest.push(0); }
Map
let arrayTest = Array.from({ length: 10000000 }, () => 0)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
For Loop fill
Array Fill
Push
Map
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
3 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.2 Safari/605.1.15
Browser/OS:
Safari 26 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
For Loop fill
184.4 Ops/sec
Array Fill
351.4 Ops/sec
Push
64.4 Ops/sec
Map
92.8 Ops/sec
Related benchmarks:
Array fill method vs for loop
Array fill method vs for loop_
Array fill method vs for loop small array
Array fill method vs push in for loop
Array fill method vs for loop vs map
Array fill method vs for loop vs push
Array fill vs Array from vs for-loop
Array fill method vs for loop3
Array fill method vs for loop test
Comments
Confirm delete:
Do you really want to delete benchmark?