Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Chrome 119
Mac OS X 10.15.7
Desktop
one year ago
Test name Executions per second
IndexOf 19002872.0 Ops/sec
Includes 25343874.0 Ops/sec
lodash 5585029.5 Ops/sec
hash.hasOwnProperty 16485157.0 Ops/sec
hashAccess 21938432.0 Ops/sec
set 24879976.0 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', 'fork', 'knife', 'test', 'case', 'stomach', 'board', 'fridge', 'chocolate', 'string', 'ben', 'phone', 'laptop', 'screen', 'keyboard', 'mouse', 'mice', 'speakers', 'mic', 'cup', 'coffee', 'pineapple', 'door', 'window', 'bed', 'room', 'dine'];
var hash = {'banana': {'thing': 14}, 'sausage': {'thing': 14}, 'fork': {'thing': 14}, 'knife': {'thing': 14}, 'test': {'thing': 14}, 'case': {'thing': 14}, 'stomach': {'thing': 14}, 'board': {'thing': 14}, 'fridge': {'thing': 14}, 'chocolate': {'thing': 14}, 'string': {'thing': 14}, 'ben': {'thing': 14}, 'phone': {'thing': 14}, 'laptop': {'thing': 14}, 'screen': {'thing': 14}, 'keyboard': {'thing': 14}, 'mouse': {'thing': 14}, 'mice': {'thing': 14}, 'speakers': {'thing': 14}, 'mic': {'thing': 14}, 'cup': {'thing': 14}, 'coffee': {'thing': 14}, 'pineapple': {'thing': 14}, 'door': {'thing': 14}, 'window': {'thing': 14}, 'bed': {'thing': 14}, 'room': {'thing': 14}, 'dine': {'thing': 14}};
var set = new Set (['banana', 'sausage', 'fork', 'knife', 'test', 'case', 'stomach', 'board', 'fridge', 'chocolate', 'string', 'ben', 'phone', 'laptop', 'screen', 'keyboard', 'mouse', 'mice', 'speakers', 'mic', 'cup', 'coffee', 'pineapple', 'door', 'window', 'bed', 'room', 'dine']);
Tests:
  • IndexOf

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

     
    array.includes('board')
  • lodash

     
    _.includes(array, 'board')
  • hash.hasOwnProperty

     
    hash.hasOwnProperty('board')
  • hashAccess

     
    hash['board'] = {'that':34}
  • set

     
    set.has('board')