Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object.fromEntries vs reduce vs classic for
(version: 1)
Comparing performance of:
Object.fromEntries vs Reduce (reuse object) vs Reduce (creating temporary objects) vs For
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
const data = Array.from(Array(10000).keys());
Tests:
Object.fromEntries
data.map((idx) => [`id-${idx}`, idx]);
Reduce (reuse object)
data.reduce((acc, idx) => { acc[`id-${idx}`] = idx; return acc; }, {});
Reduce (creating temporary objects)
data.reduce((acc, idx) => ({ ...acc, [`id-${idx}`]: idx }), {});
For
const a = {} for (let idx of data) { a[`id-${idx}`] = idx; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Object.fromEntries
Reduce (reuse object)
Reduce (creating temporary objects)
For
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?