Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
concat vs lodash.concat vs. push.apply vs. spread operator vs. push in for loop2
(version: 0)
Comparing performance of:
Array.prototype.concat vs Lodash concat vs Array.prototype.push.apply() vs spread operator vs cached for + push
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src=" https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js "></script>
Script Preparation code:
var arr1 = ["what", "is", "this"]; var arr2 = ["this", "is", "a", "test", "hello", "how", "are", "you", "today"];
Tests:
Array.prototype.concat
var result = arr1.concat(arr2);
Lodash concat
var result = _.concat(arr1, arr2);
Array.prototype.push.apply()
Array.prototype.push.apply(arr1, arr2);
spread operator
var result = [arr1, ...arr2]
cached for + push
for (var i = 0, l = arr2.length; i < l; i++) { arr1.push(arr2[i]) }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
Array.prototype.concat
Lodash concat
Array.prototype.push.apply()
spread operator
cached for + push
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?