Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object.assign vs spread vs jQuery.extend
(version: 0)
Comparing performance of:
Object.assign vs spread operator vs jQuery.extend
Created:
7 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
Tests:
Object.assign
var params = { b:"hello", c: true, d:7 }; var other = Object.assign({ a: 2 }, params);
spread operator
var params = { b:"hello", c: true, d:7 }; var other = { a: 2, ...params };
jQuery.extend
var params = { b:"hello", c: true, d:7 }; var other = $.extend({ a: 2 }, params);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Object.assign
spread operator
jQuery.extend
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
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/OS:
Chrome 135 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Object.assign
12940968.0 Ops/sec
spread operator
10954809.0 Ops/sec
jQuery.extend
6573381.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark and explain what is being tested. **Benchmark Definition** The test compares three JavaScript methods for merging objects: 1. `Object.assign()` 2. Spread operator (`...`) 3. jQuery.extend() **Options Compared** Each method has its own strengths and weaknesses, which we'll discuss next: ### Object.assign() * **Pros:** + Widely supported across browsers and platforms. + Simple to use. + Fast (average execution time). * **Cons:** + Can be slower than the spread operator in some cases. + Requires compatibility with older browsers. ### Spread Operator (`...`) * **Pros:** + Fastest average execution time among the three methods. + More concise and expressive syntax. + Widely supported across modern browsers. * **Cons:** + Limited support for older browsers (IE 11 and below). + May be slower than Object.assign() in some cases. ### jQuery.extend() * **Pros:** + Well-known and widely used library. + Supports a wider range of browsers, including older versions. + Can provide additional functionality beyond basic object merging. * **Cons:** + Adds extra weight to the code due to the inclusion of the entire jQuery library. + May be slower than other methods. **Library** The test uses jQuery 3.1.1 as the reference implementation for `jQuery.extend()`. The purpose of this function is to merge two or more objects into a single object, with the source objects' properties being overwritten by their destination values. **Special JavaScript Feature/Syntax** None are explicitly mentioned in this benchmark. **Other Alternatives** In addition to these three methods, other alternatives for merging objects include: * Using the `Object.create()` method with the `assign` property. * Utilizing a library like Lodash or Ramda, which provide more advanced features beyond basic object merging. * Implementing your own custom merge function. These alternatives may offer additional performance benefits or simplify code in specific use cases, but they are not part of the standard JavaScript API and may require additional setup.
Related benchmarks:
Object.assign vs spread operator
Object.assign vs spread operator screw jquery
Object.assign vs spread vs jQuery.extend vs property assignment
Object.assign vs spread operator vs $.extend
Comments
Confirm delete:
Do you really want to delete benchmark?