Push vs Spread

Benchmark created on


Setup

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

Test runner

Ready to run.

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

Revisions

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