Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
large list of strings: spread operator vs Array.from + push vs slice + push vs flat
Compare the new ES6 spread operator with the traditional concat() method and push
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
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:
Chrome 135
Operating system:
Windows
Device Platform:
Desktop
Date tested:
3 months ago
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
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();