Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
JavaScript spread operator vs Object.assign vs direct member access performance
(version: 1)
Comparing performance of:
Using the spread operator vs Using Object.assign vs direct member access
Created:
one year ago
by:
Guest
Jump to the latest result
Tests:
Using the spread operator
const firstObject = { sampleData: 'Hello world' } const secondObject = { moreData: 'foo bar' } const finalObject = { ...firstObject, ...secondObject };
Using Object.assign
const firstObject = { sampleData: 'Hello world' } const secondObject = { moreData: 'foo bar' } const finalObject = Object.assign(firstObject, secondObject);
direct member access
const firstObject = { sampleData: 'Hello world' } const secondObject = { moreData: 'foo bar' } const finalObject = { sampleData: firstObject['sampleData'], moreData: secondObject['moreData'] };
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Using the spread operator
Using Object.assign
direct member access
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/133.0.0.0 Safari/537.36 Edg/133.0.0.0
Browser/OS:
Chrome 133 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Using the spread operator
37505204.0 Ops/sec
Using Object.assign
40245532.0 Ops/sec
direct member access
143762640.0 Ops/sec
Related benchmarks:
JavaScript spread operator vs Object.assign performance vs access
JavaScript spread operator vs `Object.assign()` performance
JavaScript spread operator vs Object.assign with empty object literal performance
JavaScript spread operator vs Object.assign performance (test 2)
JavaScript spread operator vs Object.assign performance: empty src2
JavaScript spread operator vs Object.assign performance creating a new object
JavaScript spread operator vs Object.assign performance (same behaviour)
JavaScript spread operator vs Object.assign performance equivalent
JavaScript spread operator vs Object.assign (new object) performance
Comments
Confirm delete:
Do you really want to delete benchmark?