Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 OPR/56.0.3051.36
Opera 56
Mac OS X 10.12.6
Desktop
6 years ago
Test name Executions per second
Object.hasOwnProperty 1588567.8 Ops/sec
Object in 1032526.1 Ops/sec
Array.indexOf 239260.3 Ops/sec
direct 1210846.1 Ops/sec
Array includes 230794.6 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)