Reduce: push vs spread

Benchmark created on


Setup

const arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

Test runner

Ready to run.

Testing in
TestOps/sec
Spread
const spreadResult = arr1.reduce((acc, item) => [...acc, item], [])
ready
push
const pushResult = arr1.reduce((acc, item) => {
	acc.push(item);
	return acc;
}, [])
ready
concat
const concatResult = arr1.reduce((acc, item) => {
	return acc.concat([item]);
}, [])
ready

Revisions

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