Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
forEach mutate object vs map spread copy
(version: 0)
add field into object with forEach vs spread fields into new object with new field in array of objects
Comparing performance of:
edit field with map and spread vs edit field with forEach and mutation
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
const objects = [ { a: 'XzWtv', b: 'sFqrG', c: 'qCbnP' }, { a: 'yjkAu', b: 'vMhlE', c: 'xPqro' }, { a: 'wNztX', b: 'gDypR', c: 'iHklL' }, { a: 'mQjvs', b: 'dKzpt', c: 'aVbcO' }, { a: 'bUefZ', b: 'cRiyG', c: 'uTqxs' } ]
Tests:
edit field with map and spread
objects.map(el => ({...el, d: Math.random()}))
edit field with forEach and mutation
objects.forEach(el => {el.d = Math.random()})
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
edit field with map and spread
edit field with forEach and mutation
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!
Comments
Confirm delete:
Do you really want to delete benchmark?