Array flattening

Benchmark created on


Setup

let arr = [];
for (let index = 0; index < 100; ++index) {
  let arr2 = [];
  for (let index2 = 0; index2 < 300; ++index2) {
    arr2.push((Math.random() + 1).toString(36).substring(7));
  }
  arr.push(arr2);
}

Test runner

Ready to run.

Testing in
TestOps/sec
concat.apply
let flattenedArray = [].concat.apply([], arr);
ready
flat
let flattenedArray = arr.flat();
ready

Revisions

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