Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.1.0 Chrome/94.0.4606.51 Electron/15.0.0 Safari/537.36
Chrome 94
Windows
Desktop
3 years ago
Test name Executions per second
IndexOf 8577463.0 Ops/sec
Includes 9198443.0 Ops/sec
lodash 2454409.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 array = ['banana', 'sausage', 'jesus']
Tests:
  • IndexOf

     
    array.indexOf('sausage') !== 1
  • Includes

     
    array.includes('sausage')
  • lodash

     
    _.includes(array, 'sausage')