Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
Chrome 105
Linux
Desktop
2 years ago
Test name Executions per second
Lodash 360938.0 Ops/sec
Native 984349.5 Ops/sec
HTML Preparation code:
x
 
1
2
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
 
var max2 = 100;
var data = [];
for (var i = 0; i <= max2; i++) { data.push({ id: i }); }
Tests:
  • Lodash

     
    _.groupBy(data, ({ id }) => id)
  • Native

     
    data.reduce((acc, item) => {
            acc[item.id] = item;
            return acc;
    }, {})