Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object.fromEntries vs reduce with keys as indexes
(version: 0)
Comparing performance of:
With reduce with an id inside the object vs with Object.fromEntries ( array.map( ... ) ) with an id inside the object
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var data = [{ test: 1, test: 1, test: 1, test: 1, test: 1, test: 1 }, { test: 1, test: 1, test: 1, test: 1, test: 1, test: 1 }, { test: 1, test: 1, test: 1, test: 1, test: 1, test: 1 }, { test: 1, test: 1, test: 1, test: 1, test: 1, test: 1 }, { test: 1, test: 1, test: 1, test: 1, test: 1, test: 1 }, { test: 1, test: 1, test: 1, test: 1, test: 1, test: 1 }]
Tests:
With reduce with an id inside the object
data.reduce((previousKeys, actualKey, indexKey) => { previousKeys[ indexKey ] = { id: indexKey, order: indexKey, ...actualKey }; return previousKeys; }, {});
with Object.fromEntries ( array.map( ... ) ) with an id inside the object
Object.fromEntries(data.map((key, value) => [ value, { id: value, ...key } ]));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
With reduce with an id inside the object
with Object.fromEntries ( array.map( ... ) ) with an id inside the 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.fromEntries vs reduce v3
Object.fromEntries on array vs reduce on array
Object.fromEntries vs reduce v21
Object.fromEntries vs reduce round 2
push vs spread (reduce array)
Comments
Confirm delete:
Do you really want to delete benchmark?