Script Preparation code:
x
 
function shuffle(array) {
  let currentIndex = array.length,  randomIndex;
  // While there remain elements to shuffle...
  while (currentIndex != 0) {
    // Pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex--;
    // And swap it with the current element.
    [array[currentIndex], array[randomIndex]] = [
      array[randomIndex], array[currentIndex]];
  }
  return array;
}
var a = shuffle(Array(100000).fill(undefined).map((_, i) => i));
var b = a.reduce((acc, el) => { acc[el] = true; return acc }, {});
var c = new Set(a);
var d = new Map(a.map(el => [el, true]));
var elements = [1, 100, 1000, 24, 56, 78, 23, 5643, 863, 2679, 9999, 45, 5832, 7510, 3756];
Tests:
  • includes

     
    return elements.map(el => a.includes(el))
  • hash

     
    return elements.map(el => b[el])
  • set

     
    return elements.map(el => c.has(el))
  • map

     
    return elements.map(el => d.get(el))
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    includes
    hash
    set
    map

    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/96.0.4664.110 Safari/537.36
Chrome 96 on Windows
View result in a separate tab
Test name Executions per second
includes 1118.2 Ops/sec
hash 881811.9 Ops/sec
set 776648.6 Ops/sec
map 750669.1 Ops/sec