Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
compare the ways to generate an empty array for iteration
- Array.apply: Array.apply(null, Array(100)) - Destructuring operator: [...Array(100)] - Array.prototype.fill Array(100).fill(undefined) - Array.from Array.from({ length: 100 })
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array.apply(null, Array(n))
231628.6 Ops/sec
[...Array(n)]
259000.8 Ops/sec
Array(n).fill(null)
320550.9 Ops/sec
Array.from({ length: n })
28944.0 Ops/sec
Array.from({ length:n }, (item, i) => i)
25383.3 Ops/sec
Tests:
Array.apply(null, Array(n))
Array.apply(null, Array(1000)).map((item, i) => i);
[...Array(n)]
[...Array(1000)].map((item, i) => i);
Array(n).fill(null)
Array(1000).fill(null).map((item, i) => i);
Array.from({ length: n })
Array.from({ length: 1000 }).map((item, i) => i);
Array.from({ length:n }, (item, i) => i)
Array.from({ length:1000 }, (item, i) => i);