Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.from() vs new Array() vs push vs [i] pushup
(version: 0)
Testing the difference between creating filled arrays.
Comparing performance of:
new Array() vs Array.from() vs push vs [i]
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
new Array()
new Array(500).fill("push-up", 0, 500)
Array.from()
Array.from({ length: 500 }, () => "push-up")
push
let array = []; for (let i = 0; i < 500; i++){ array.push("push-up") }
[i]
let array = []; for (let i = 0; i < 500; i++){ array[i] = "push-up" }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
new Array()
Array.from()
push
[i]
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Browser/OS:
Chrome 122 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
new Array()
546069.5 Ops/sec
Array.from()
28793.0 Ops/sec
push
454521.4 Ops/sec
[i]
374832.4 Ops/sec
Related benchmarks:
Array.from() vs new Array()
Array.from() vs new Array() - empty
Array.from() vs new Array().map()
Array.from() vs new Array() vs push
Array.from() vs new Array() vs push pushup
Comments
Confirm delete:
Do you really want to delete benchmark?