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 (Macintosh; Intel Mac OS X 10.15; rv:129.0) Gecko/20100101 Firefox/129.0
Browser:
Firefox 129
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array.flat
4707451.0 Ops/sec
reduce + concat
3277561.8 Ops/sec
reduce + destructure
2282524.0 Ops/sec
reduce + push
4746022.5 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), []);