Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Chrome 134
Windows
Desktop
11 days ago
Test name Executions per second
Object.hasOwnProperty 30572426.0 Ops/sec
Object in 52076588.0 Ops/sec
Array.indexOf 895926.6 Ops/sec
direct 51595324.0 Ops/sec
Array includes 894216.4 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)