Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Initializing array with n undefined items
worth to note that the maximum callstack size is exceeded for the first test case (spread operator) with n = 1 million
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0.1 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 18
Operating system:
iOS 18.0.1
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
[...Array(n).keys()].map(k => undefined)
210.9 Ops/sec
Array.apply(null, { length: 4 })
0.0 Ops/sec
Array.from
220.6 Ops/sec
Array(n).fill(undefined)
18228.0 Ops/sec
for loop push
151.9 Ops/sec
Script Preparation code:
var n = 100000; // 100k
Tests:
[...Array(n).keys()].map(k => undefined)
[...Array(n).keys()].map(k => undefined);
Array.apply(null, { length: 4 })
Array.apply(null, { length: n });
Array.from
Array.from({ length: n }, () => undefined);
Array(n).fill(undefined)
Array(n).fill(undefined)
for loop push
const arr = []; for (let i = 0; i < n; i++) { arr.push(undefined); }