Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.prototype.concat vs spread operatorssssssssssssssssssssssssssss
(version: 0)
Compare the new ES6 spread operator with the traditional concat() method
Comparing performance of:
Array.prototype.concat vs spread operator vs jQuery merge
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
Array.prototype.concat
var params = [ { message: 'A' } ]; var paramss = [ { message: 'B' } ]; var other = [ ...params, ...paramss ];
spread operator
var params = [ { message: 'A' } ]; var paramss = [ { message: 'B' } ]; var other = params.push(...paramss);
jQuery merge
var params = [ { message: 'A' } ]; var paramss = [ { message: 'B' } ]; var other = params.concat(paramss)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Array.prototype.concat
spread operator
jQuery merge
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser/OS:
Chrome 121 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Array.prototype.concat
39103472.0 Ops/sec
spread operator
70528800.0 Ops/sec
jQuery merge
16497649.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Overview** The provided benchmark, "Array.prototype.concat vs spread operators", is designed to compare the performance of three different approaches: the traditional `concat()` method, the new ES6 spread operator (`...`), and the jQuery `merge` function. **Test Case Breakdown** There are three individual test cases: 1. **`Array.prototype.concat`**: This test case uses the traditional `concat()` method to concatenate two arrays. 2. **Spread Operator**: This test case uses the new ES6 spread operator (`...`) to concatenate two arrays. 3. **jQuery merge**: This test case uses the jQuery `merge` function to concatenate two arrays. **Options Compared** The benchmark is comparing the performance of: * Traditional `concat()` method * New ES6 spread operator (`...`) * jQuery `merge` function **Pros and Cons** Here's a brief overview of each approach: 1. **Traditional `concat()` method**: * Pros: widely supported, easy to understand. * Cons: can be slow for large arrays due to its iterative nature. 2. **New ES6 spread operator (`...`)**: * Pros: concise and expressive, efficient for small arrays. * Cons: may not work as expected for very large arrays or complex data structures. 3. **jQuery `merge` function**: * Pros: optimized for performance, widely used in jQuery libraries. * Cons: specific to jQuery, may require additional setup. **Library and Syntax Used** The test case uses the jQuery library for the `merge` function, which is a proprietary function developed by Microsoft. There are no special JavaScript features or syntax used in this benchmark. **Other Alternatives** If you're looking for alternatives to these approaches, consider: * Using `Array.prototype.reduce()` instead of `concat()`. * Using `Array.prototype.push()` with the spread operator (`...`) for a more concise solution. * Implementing your own custom concatenation function for optimal performance. Keep in mind that these alternatives may have different trade-offs and performance characteristics compared to the approaches tested in this benchmark.
Related benchmarks:
concat 2 arrays: Array.prototype.concat vs spread operator
Array.prototype.concat vs spread operator (add)
Array.prototype.concat vs spread operator (fix)
Array.prototype.concat vs spread operator on large array
Array.prototype.concat vs spread operator on small array
Comments
Confirm delete:
Do you really want to delete benchmark?