Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Loop into two arrays
(version: 0)
Compare the new ES6 spread operator with the traditional concat() method
Comparing performance of:
Array reduce vs Array for
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
Array reduce
const result = products.reduce((selectionData, product) => { if (!selectors.getInUse(getState(), product)) { if (isChecked) { selectionData[product.id] = CHECKBOX_STATUS.CHECKED; } } return selectionData; }, {}); console.log(result);
Array for
const selectionData = {}; for (let i = 0; i < products.length; i++) { const product = products[i]; if (!selectors.getInUse(getState(), product)) { if (isChecked) { selectionData[product.id] = CHECKBOX_STATUS.CHECKED; } } } console.log(result);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Array reduce
Array 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?