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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Browser:
Chrome 145
Operating system:
Linux
Device Platform:
Desktop
Date tested:
4 months ago
Array(n).fill(null)
456K/s
[...Array(n)]
426K/s
Array.apply(null, Array(n))
193K/s
Array.from({ length: n })
24K/s
Array.from({ length:n }, (item, i) => i)
23K/s
View exact numbers
Test name
Executions per second
✓
Array(n).fill(null)
456,427 Ops/sec
[...Array(n)]
426,168 Ops/sec
Array.apply(null, Array(n))
192,622 Ops/sec
Array.from({ length: n })
24,356 Ops/sec
Array.from({ length:n }, (item, i) => i)
23,132 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);