Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Pushing onto an array in a loop vs pushing with the spread operator
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36
Browser:
Chrome 148
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
23 days ago
Test name
Executions per second
Push with a for...of loop
5973162.5 Ops/sec
Push with spread
8953680.0 Ops/sec
Push with a classic for loop
1795697.0 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const data = new Array(100); data.fill(1);
Tests:
Push with a for...of loop
const destination = []; for (const elem of data) { destination.push(elem); }
Push with spread
const destination = []; destination.push(...data);
Push with a classic for loop
const destination = []; for (let i = 0; i < data.length; i++) { destination.push(data[i]); }