Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.flat vs (reduce + concat) vs (reduce + destructure) vs (reduce + push)
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/121.0.0.0 Safari/537.36
Browser:
Chrome 121
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Array.flat
2182923.0 Ops/sec
reduce + concat
1962389.8 Ops/sec
reduce + destructure
3692905.2 Ops/sec
reduce + push
4722318.0 Ops/sec
Tests:
Array.flat
const params = [[1, 2], ["hello", true, 7], [null, undefined, {}], [1, 2, 3, 4, 5], [false, true, {}, {}, {}]]; params.flat();
reduce + concat
const params = [[1, 2], ["hello", true, 7], [null, undefined, {}], [1, 2, 3, 4, 5], [false, true, {}, {}, {}]]; params.reduce((acc, val) => acc.concat(val), []);
reduce + destructure
const params = [[1, 2], ["hello", true, 7], [null, undefined, {}], [1, 2, 3, 4, 5], [false, true, {}, {}, {}]]; params.reduce((acc, curr) => [...acc, ...curr], []);
reduce + push
const params = [[1, 2], ["hello", true, 7], [null, undefined, {}], [1, 2, 3, 4, 5], [false, true, {}, {}, {}]]; params.reduce((acc, curr) => (acc.push(...curr), acc), []);