Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 Edg/104.0.1293.63
Chrome 104
Windows
Desktop
2 years ago
Test name Executions per second
lorem.startsWith("L"); 12157057.0 Ops/sec
lorem.indexOf("L") === 0; 12266234.0 Ops/sec
LOREM_RE.test(lorem); 5250099.5 Ops/sec
lorem.startsWith("R"); 11764537.0 Ops/sec
lorem.indexOf("R") === 0; 10726365.0 Ops/sec
ROLEM_RE.test(lorem); 5245593.5 Ops/sec
lorem && lorem[0] === "L"; 5971257.0 Ops/sec
Script Preparation code:
Tests:
  • lorem.startsWith("L");

  • lorem.indexOf("L") === 0;

  • LOREM_RE.test(lorem);

  • lorem.startsWith("R");

  • lorem.indexOf("R") === 0;

  • ROLEM_RE.test(lorem);

  • lorem && lorem[0] === "L";