Script Preparation code:
x
 
var array = [];
for (var i=0; i<300; ++i) {
    array.push('00' + i);
}
function hasWithIndexOf(needle) {
    return array.indexOf(needle) !== -1;
}
var map = new Set();
array.forEach(item => map.add(item));
function hasWithMap(needle) {
    return map.has(needle);
}
Tests:
  • array

     
    for (var i=0; i<100; ++i) {
        hasWithIndexOf('404');
    }
  • map

     
    for (var i=0; i<100; ++i) {
        hasWithMap('404');
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    array
    map

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0
Firefox 136 on Windows
View result in a separate tab
Test name Executions per second
array 22376.2 Ops/sec
map 2174710.2 Ops/sec