Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
large list of strings: spread operator vs Array.from + push vs slice + push vs flat
(version: 1)
Compare the new ES6 spread operator with the traditional concat() method and push
Comparing performance of:
spread operator vs Array.from + push vs Slice + push vs flat
Created:
3 months ago
by:
Guest
Jump to the latest result
Script Preparation code:
const largeList = Array.from({length: 100_000}).map((_, idx) => `${idx}`.padStart(30, '0'));
Tests:
spread operator
const newList = [...largeList, 'a new string'];
Array.from + push
const newList = Array.from(largeList); newList.push('a new string');
Slice + push
const newList = largeList.slice(); newList.push('a new string');
flat
const newList = [largeList, ['a new string']].flat();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
spread operator
Array.from + push
Slice + push
flat
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
3 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Browser/OS:
Chrome 135 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
spread operator
3480.1 Ops/sec
Array.from + push
3343.6 Ops/sec
Slice + push
3196.5 Ops/sec
flat
821.2 Ops/sec
Related benchmarks:
Array concat vs spread operator vs push___
Array concat vs spread operator vs push____
Large Array concat vs spread operator vs push
Array concat vs spread operator vs push (Super Big Array)
Array concat vs spread operator vs push with more data
Array concat vs spread operator vs push larger list
Array concat vs spread operator vs push (cycle)
Array concat vs spread operator vs push large array
Array concat vs spread operator vs push large with smaller array added
Comments
Confirm delete:
Do you really want to delete benchmark?