Push vs Spread2 (v2)

Revision 2 of this benchmark created on


Setup

const a = [...new Array(1000)].map((_, i) => i);
const a2 = [...new Array(1000)].map((_, i) => 2 * i);

Test runner

Ready to run.

Testing in
TestOps/sec
Push (for...of)
const b = []
for (const i of a) {
	b.push(i * 3);
}
for (const i of a2) {
	b.push(i * 3);
}
ready
Push (for...i)
const b = [];
for (let i = 0; i < a.length; i++) {
	b.push(a[i] * 3);
}
for (let i = 0; i < a2.length; i++) {
	b.push(a2[i] * 3);
}
ready
Spread
const b = [...a, ...a2].map((i) => i * 3);
ready

Revisions

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