Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:108.0) Gecko/20100101 Firefox/108.0
Firefox 108
Mac OS X 10.15
Desktop
2 years ago
Test name Executions per second
indexOf 1837045.1 Ops/sec
Lodash IndexOf 928184.4 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:
 
data = Array.from({length: 1000}).map((e, index) => index);
Tests:
  • indexOf

     
    const result = data.indexOf(999);
  • Lodash IndexOf

     
    const result = _.indexOf(data, 999);