Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.reduce
(version: 0)
Comparing performance of:
reduce vs foreach
Created:
7 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
const data = []; for (let i = 0; i < 1000; i ++) { data.push([String(i), i]); }
Tests:
reduce
const data = []; for (let i = 0; i < 1000; i ++) { data.push([String(i), i]); } data.reduce((p, c) => Object.assign(p, c), {});
foreach
const data = []; for (let i = 0; i < 1000; i ++) { data.push([String(i), i]); } const p = {}; data.forEach(c => { p[c[0]] = c[1]; });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
reduce
foreach
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:
Reduce vs push
Test length assign
Test length assign 100k
Test length assign 1000
Comments
Confirm delete:
Do you really want to delete benchmark?