Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Chrome 131
Windows
Desktop
one month ago
Test name Executions per second
includes 2943673.2 Ops/sec
lookup 3376785.8 Ops/sec
indexof 2915953.2 Ops/sec
object 2961536.5 Ops/sec
Script Preparation code:
x
 
var a = [
  'height',
  'width',
  'maxHeight',
  'maxWidth',
  'maxHeight',
  'minWidth',
  'color',
  'bg',
  'backgroundColor',
  'opacity',
  'm',
  'mt',
  'mb',
  'mr',
  'mr',
  'mx',
  'my',
  'p',
  'pt',
  'pb',
  'pr',
  'pl',
  'px',
  'py',
  'border',
  'boxShadow',
  'flex',
  'verticalAlign',
  'textAlign',
  'overflow',
  'display',
  'cursor',
  '1height',
'1width',
'1maxHeight',
'1maxWidth',
'1maxHeight',
'1minWidth',
'1color',
'1bg',
'1backgroundColor',
'1opacity',
'1m',
'1mt',
'1mb',
'1mr',
'1mr',
'1mx',
'1my',
'1p',
'1pt',
'1pb',
'1pr',
'1pl',
'1px',
'1py',
'1border',
'1boxShadow',
'1flex',
'1verticalAlign',
'1textAlign',
'1overflow',
'1display',
'1cursor',
'2height',
'2width',
'2maxHeight',
'2maxWidth',
'2maxHeight',
'2minWidth',
'2color',
'2bg',
'2backgroundColor',
'2opacity',
'2m',
'2mt',
'2mb',
'2mr',
'2mr',
'2mx',
'2my',
'2p',
'2pt',
'2pb',
'2pr',
'2pl',
'2px',
'2py',
'2border',
'2boxShadow',
'2flex',
'2verticalAlign',
'2textAlign',
'2overflow',
'2display',
'2cursor',
'3height',
'3width',
'3maxHeight',
'3maxWidth',
'3maxHeight',
'3minWidth',
'3color',
'3bg',
'3backgroundColor',
'3opacity',
'3m',
'3mt',
'3mb',
'3mr',
'3mr',
'3mx',
'3my',
'3p',
'3pt',
'3pb',
'3pr',
'3pl',
'3px',
'3py',
'3border',
'3boxShadow',
'3flex',
'3verticalAlign',
'3textAlign',
'3overflow',
'3display',
'3cursor'
  
];
var count = 120;
a = a.slice(0, count);
var b = new Set(a)
var c = Object.fromEntries(a.map(value => [value, true]));
Tests:
  • includes

     
    return a.includes(a[Math.round(Math.random() * count)])
  • lookup

     
    return b.has(a[Math.round(Math.random() * count)])
  • indexof

     
    return a.indexOf(a[Math.round(Math.random() * count)]) >= 0
  • object

     
    return c[a[Math.round(Math.random() * count)]]