Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Loop into two arrays with products
Compare the new ES6 spread operator with the traditional concat() method
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Browser:
Chrome 119
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Array reduce
374803.0 Ops/sec
Array for
532097.8 Ops/sec
Tests:
Array reduce
const products = [{id: '189234'}, {id: '12434'}, {id: '12354'}, {id: '13234'}, {id: '12134'}, {id: '12342'}, {id: '12349'}, {id: '12348'}, {id: '12374'}, {id: '12364'}, {id: '12345'}] const result = products.reduce((selectionData, product) => { selectionData[product.id] = true; return selectionData; }, {});
Array for
const selectionData = {}; const products = [{id: '189234'}, {id: '12434'}, {id: '12354'}, {id: '13234'}, {id: '12134'}, {id: '12342'}, {id: '12349'}, {id: '12348'}, {id: '12374'}, {id: '12364'}, {id: '12345'}] for (let i = 0; i < products.length; i++) { const product = products[i]; selectionData[product.id] = true; }