Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Test_Currency
(version: 0)
Comparing performance of:
forEach vs Reduce
Created:
5 years ago
by:
Guest
Jump to the latest result
Tests:
forEach
const currency = [{ usd: 5 }, { uah: 10 }, { usd: 3 }]; const merge = (data) => { const res = {}; data.forEach((item) => { for (let [key, value] of Object.entries(item)) { !res[key] ? (res[key] = value) : (res[key] += value); } }); return res; };
Reduce
const currency = [{ usd: 5 }, { uah: 10 }, { usd: 3 }]; const result = currency.reduce((res, item) => { for (const [key, value] of Object.entries(item)) { !res[key] ? (res[key] = value) : (res[key] = res[key] + value); } return res; }, {});
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
forEach
Reduce
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:
Number.toLocaleString vs Intl.NumberFormat
cached Intl.NumberFormat vs new Intl.NumberFormat vs toLocaleString currency
cached Intl.NumberFormat vs new Intl.NumberFormat vs Number toLocaleString currency
Intl.NumberFormat vs Number.toLocaleString
test international
Comments
Confirm delete:
Do you really want to delete benchmark?