Script Preparation code:
AخA
 
var object = {},
    array = [],
    set = new Set();
let i;
  
for (i = 0; i < 1000; i++) {
    object['something' + i] = true;
    array.push('something' + i);
    set.add('something' + i);
}
Tests:
  • Object.hasOwnProperty

     
    object.hasOwnProperty('something' + Math.floor(Math.random() * 1000))
  • Object in

     
    ('something' + Math.floor(Math.random() * 1000)) in object
  • Array.indexOf

     
    array.indexOf('something' + Math.floor(Math.random() * 1000)) !== -1
  • direct

     
    object['something' + Math.floor(Math.random() * 1000)]
  • Array includes

     
    array.includes('something' + Math.floor(Math.random() * 1000))
  • Set has

     
    set.has('something' + Math.floor(Math.random() * 1000))
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Object.hasOwnProperty
    Object in
    Array.indexOf
    direct
    Array includes
    Set has

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36
Chrome 92 on Windows
View result in a separate tab
Test name Executions per second
Object.hasOwnProperty 1543042.4 Ops/sec
Object in 1357842.9 Ops/sec
Array.indexOf 225389.0 Ops/sec
direct 1729548.6 Ops/sec
Array includes 217106.8 Ops/sec
Set has 1822450.8 Ops/sec