Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Returning a parsed object
(version: 0)
Comparing performance of:
Spread operator vs Cloning vs Object.assign()
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var object = { title: 'title', subtitle: 'subtitle', description: 'Learn more about URL shortening. Short links come with 100% free accounts. Get private click stats, QR codes and basic tagging. Or upgrade with dozens of powerful features in paid plans starting at $5. Special discount for tiny.cc users!', someInt: 5, someOtherInt: 10.5, arr: [ { title: 'title', subtitle: 'subtitle', description: 'Learn more about URL shortening. Short links come with 100% free accounts. Get private click stats, QR codes and basic tagging. Or upgrade with dozens of powerful features in paid plans starting at $5. Special discount for tiny.cc users!', someInt: 5, someOtherInt: 10.5 }, { title: 'title', subtitle: 'subtitle', description: 'Learn more about URL shortening. Short links come with 100% free accounts. Get private click stats, QR codes and basic tagging. Or upgrade with dozens of powerful features in paid plans starting at $5. Special discount for tiny.cc users!', someInt: 5, someOtherInt: 10.5 }, { title: 'title', subtitle: 'subtitle', description: 'Learn more about URL shortening. Short links come with 100% free accounts. Get private click stats, QR codes and basic tagging. Or upgrade with dozens of powerful features in paid plans starting at $5. Special discount for tiny.cc users!', someInt: 5, someOtherInt: 10.5 }, { title: 'title', subtitle: 'subtitle', description: 'Learn more about URL shortening. Short links come with 100% free accounts. Get private click stats, QR codes and basic tagging. Or upgrade with dozens of powerful features in paid plans starting at $5. Special discount for tiny.cc users!', someInt: 5, someOtherInt: 10.5 } ] }
Tests:
Spread operator
function merged () { return { ...object, arr: null, } } for (let i = 0; i < 10000; i++) { console.log(merged()) }
Cloning
function merged () { const clone = JSON.parse(JSON.stringify(object)) delete clone.arr return clone } for (let i = 0; i < 10000; i++) { console.log(merged()) }
Object.assign()
function merged () { const changes = { arr: null } return Object.assign({}, object, changes); } for (let i = 0; i < 10000; i++) { console.log(merged()) }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Spread operator
Cloning
Object.assign()
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:
_.get Benchmark Test
Lodash.get vs native
Lodash.get vs native with optional chaining
Optional chaining vs native code v3
Lodash.get vs Optional chaining 1234
Comments
Confirm delete:
Do you really want to delete benchmark?