Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0
Firefox 88
Windows
Desktop
3 years ago
Test name Executions per second
lorem.startsWith("L"); 24162766.0 Ops/sec
lorem.indexOf("L") === 0; 18868416.0 Ops/sec
LOREM_RE.test(lorem); 15653137.0 Ops/sec
lorem.startsWith("R"); 24900338.0 Ops/sec
lorem.indexOf("R") === 0; 11927928.0 Ops/sec
ROLEM_RE.test(lorem); 18255120.0 Ops/sec
lorem && lorem[0] === "L"; 204842400.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";