reduce with spread vs array.push

Benchmark created on


Setup

const data = [];
for (let i = 0; i < 100000; i++) {
    data.push(i);
}

Test runner

Ready to run.

Testing in
TestOps/sec
Reduce with spread
data.reduce(
(acc, point) => [...acc, point],
 []);
ready
array push
const acc = [];
for (point of data) {
	acc.push(point);
}
ready

Revisions

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