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:
6 months ago
by:
Guest
Go 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:
6 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
Array Fill
351/s
For Loop fill
184/s
Map
93/s
Push
64/s
View exact numbers
Test name
Executions per second
✓
Array Fill
351 Ops/sec
For Loop fill
184 Ops/sec
Map
93 Ops/sec
Push
64 Ops/sec
Related benchmarks
Array fill method vs for loop
Array fill method vs for loop vs push
Array fill vs Array from vs for-loop
Array fill method vs for loop test
Comments
Confirm delete:
Do you really want to delete benchmark?