Run details:
Mozilla/5.0 (Linux; Android 7.0; SM-A510F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Mobile Safari/537.36
Chrome Mobile 72
Android 7.0
Mobile
6 years ago
Test name Executions per second
Object.hasOwnProperty 339988.3 Ops/sec
Object in 251927.0 Ops/sec
Array.indexOf 53225.0 Ops/sec
direct 315387.9 Ops/sec
Array includes 54229.1 Ops/sec
Script Preparation code:
AخA
 
  var object = {},
      array = [],
      i, test = 1000;
  
  for (i = 0; i < 1000; i++) {
   object['something' + i] = true;
   array.push('something' + i);
  }
Tests:
  • Object.hasOwnProperty

     
    object.hasOwnProperty('something' + test)
  • Object in

     
    ('something' + test) in object
  • Array.indexOf

     
    array.indexOf('something' + test) !== -1
  • direct

     
    object['something' + test] === true
  • Array includes

     
    array.includes('something' + test)