Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36
Chrome 93
Windows
Desktop
3 years ago
Test name Executions per second
Lodash 140.7 Ops/sec
Native 343.7 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 = 100000;
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;
    }, {})