Push, spread, concat for combining and flattening arrays

Benchmark created on


Setup

const arrays = Array.from({length: 100}).map((_, i) => new Array(50).fill(i));

Test runner

Ready to run.

Testing in
TestOps/sec
Push spread
const joined = [];
for (const arr of arrays) {
	joined.push(...arr);
}
ready
concat with spread
const joined = [].concat(...arrays);
ready
Repeated concats
let joined = [];
for (const arr of arrays) {
	joined = joined.concat(arr);
}
ready

Revisions

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