Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array concat vs spread vs push spread, loop, apply
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 (iPhone; CPU iPhone OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 17
Operating system:
iOS 17.4
Device Platform:
Mobile
Date tested:
2 years ago
Test name
Executions per second
Array.prototype.concat
412055.4 Ops/sec
spread operator
70708.9 Ops/sec
Push Spread
143447.8 Ops/sec
Push Apply
1110371.2 Ops/sec
Push Loop
783696.5 Ops/sec
Script Preparation code:
var subarrs = [ [ "hello", true, 7 ], [ "yes", "no", "maybe", false, 27 ], [ 16, "I", "wonder", "what", "will", "be", "fastest"] ];
Tests:
Array.prototype.concat
var other = [ 1, 2, 3 ] for (var len = subarrs.length, i = 0; i < len; i++){ other = other.concat(subarrs[i]); } return other;
spread operator
var other = [ 1, 2, 3 ] for (var len = subarrs.length, i = 0; i < len; i++){ other = [ ...other, ...subarrs[i] ] } return other;
Push Spread
var other = [ 1, 2, 3 ] for (var len = subarrs.length, i = 0; i < len; i++){ other.push(...subarrs[i]); } return other;
Push Apply
var other = [ 1, 2, 3 ] for (var len = subarrs.length, i = 0; i < len; i++){ other.push.apply(other, subarrs[i]); } return other;
Push Loop
var other = [ 1, 2, 3 ] for (var len = subarrs.length, i = 0; i < len; i++){ for (var jarr = subarrs[i], jen = jarr.length, j = 0; j < jen; j++){ other.push(jarr[j]); } } return other;