Array flattening (v3)

Revision 3 of this benchmark created on


Setup

let arr = new Array(30_000).fill(new Array(3_000).fill(1))

Test runner

Ready to run.

Testing in
TestOps/sec
concat.apply
let flattenedArray = [].concat.apply([], arr);
ready
flat
let flattenedArray = arr.flat();
ready
spread + concat
let flattenedArray = [].concat(...arr)
ready
manual for
let flattened = [];
for (let i = 0; i < arr.length; i++) {
    for (let j = 0; j < arr[i].length; j++) {
        flattened.push(arr[i][j])
    }
}
ready

Revisions

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