Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
IndexOf vs Includes vs hash vs set
Banana
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Browser:
Chrome 136
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
IndexOf
54957608.0 Ops/sec
Includes
44961916.0 Ops/sec
lodash
18633496.0 Ops/sec
hash.hasOwnProperty
48496836.0 Ops/sec
hashAccess
73013192.0 Ops/sec
set
108894008.0 Ops/sec
HTML Preparation code:
<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')