Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.prototype.concat vs spread operator vs stringify
Compare the new ES6 spread operator with the traditional concat() method
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/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array.prototype.concat
1949606.6 Ops/sec
spread operator
506063.3 Ops/sec
stringify
56285.2 Ops/sec
concat apply
1482389.5 Ops/sec
loop
18208.7 Ops/sec
Script Preparation code:
var array1 = Array(400).fill().map(() => Math.round(Math.random() * 40)); var array2 = Array(400).fill().map(() => Math.round(Math.random() * 40));
Tests:
Array.prototype.concat
var others = array1.concat(array2);
spread operator
var others = [...array1, ...array2];
stringify
var others = JSON.parse((JSON.stringify(array1)+JSON.stringify(array2)).replace('][',','))
concat apply
var others = Array.prototype.concat.apply([], [array1, array2]);
loop
var others = []; for (var i = 0; i < 400; i+=1) { others[i] = array1[i] } for (var i = 400; i < 800; i+=1) { others[i] = array2[i] }