Flattening Arrays

Benchmark published by System on

Description

Compare flat() vs reduce+concat.

Setup

const arr = Array.from({length: 100}, () => [1, 2, 3]);

Test Runner

Initializing...

Testing in
Test CaseOps/sec
Array.flat
arr.flat();
ready
reduce & concat
arr.reduce((acc, val) => acc.concat(val), []);
ready
Spread & concat
[].concat(...arr);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

Revision 1
publishedby Systemon