Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Chrome 95
Windows
Desktop
3 years ago
Test name Executions per second
map 3519979.5 Ops/sec
set 3270291.5 Ops/sec
arr 333034.3 Ops/sec
symbol 3358327.0 Ops/sec
uid 3221204.5 Ops/sec
control 4663772.0 Ops/sec
Script Preparation code:
x
 
var
map = new Map(),
set = new Set(),
arr = [],
sym = Symbol(),
uid = "some-uid",
item = {};  // not in any
// Create
for (var i = 0; i < 5000; ++i)
{
  var obj = {};
  map.set(obj, true);
  set.add(obj);
  arr.push(obj);
  obj[sym] = true;
  obj[uid] = true;
}
function mapHas(thing)
{
  return map.has(thing);
}
function setHas(thing)
{
  return set.has(thing);
}
function arrHas(thing)
{
  return arr.indexOf(thing) >= 0;
}
function symHas(thing)
{
  return thing[sym];
}
function uidHas(thing)
{
  return thing[uid];
}
function conHas(thing)
{
  return false;
}
Tests:
  • map

     
    mapHas(item);
  • set

     
    setHas(item);
  • arr

     
    arrHas(item);
  • symbol

     
    symHas(item);
  • uid

     
    uidHas(item);
  • control

     
    conHas(item);