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 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/113.0
Browser:
Firefox 113
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Array reduce
1663789.6 Ops/sec
Array for
1703934.2 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; }