Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 YaBrowser/20.4.3.257 Yowser/2.5 Yptp/1.23 Safari/537.36
Yandex Browser 20
Windows
Desktop
4 years ago
Test name Executions per second
Set set 6593364.5 Ops/sec
Get set 6591761.0 Ops/sec
Set dict 7071026.0 Ops/sec
Get dict 7088184.5 Ops/sec
Script Preparation code:
AخA
 
s = new Set();
d = {};
for (var i=0;i<10;i++){
  s.add(i);
  d[i]=true;
}
Tests:
  • Set set

     
    s.add(5)
  • Get set

     
    s.has(3)
  • Set dict

     
    d[5] = true
  • Get dict

     
    d[5]