Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Create vs Mutate Object 2
(version: 3)
Comparing performance of:
Create new object vs Mutate object vs Destructure vs Add new properties vs Just mutate in-place
Created:
4 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var collection = new Array(10000).map(item => ({a:null, b:null, c:null}))
Tests:
Create new object
collection.map(() => { return {a:1, b:1, c:1} })
Mutate object
collection.map((obj) => { obj.a = 1 obj.b = 1 obj.c = 1 return obj })
Destructure
collection.map((obj) => { return {...obj, a:1, b:1, c:1} })
Add new properties
collection.map((obj) => { obj.d = 1 obj.e = 1 obj.f = 1 return obj })
Just mutate in-place
collection.forEach((obj) => { obj.a = 1 obj.b = 1 obj.c = 1 })
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
Create new object
Mutate object
Destructure
Add new properties
Just mutate in-place
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:
creating array
sadsasdadsad
Object.fromEntries vs reduce v3
lodash entries vs object entries
Comments
Confirm delete:
Do you really want to delete benchmark?