Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Spread vs Object.assign vs Object.keys with forEach (without new object)1
(version: 1)
Comparing performance of:
Using the spread operator vs Using Object.assign vs Overriding the first object
Created:
3 years ago
by:
Registered User
Jump to the latest result
Tests:
Using the spread operator
let firstObject = { sampleData: 'Hello world' }; const secondObject = { moreData: 'foo bar' }; firstObject = { ...firstObject, ...secondObject };
Using Object.assign
let firstObject = { sampleData: 'Hello world' }; const secondObject = { moreData: 'foo bar' }; Object.assign(firstObject, secondObject);
Overriding the first object
let firstObject = { sampleData: 'Hello world' } const secondObject = { moreData: 'foo bar' } Object.keys(secondObject).forEach(key => {firstObject[key] = secondObject[key] })
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
Overriding the first object
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!
Related benchmarks:
object assign vs object spread on growing objects
object.assign vs spread to create a copy
object spread vs Object.assign
Object.assign() vs spread operator (New object)
Comments
Confirm delete:
Do you really want to delete benchmark?