Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36
Chrome 91
Mac OS X 10.15.7
Desktop
3 years ago
Test name Executions per second
lorem.startsWith("L"); 13167242.0 Ops/sec
lorem.indexOf("L") === 0; 12259741.0 Ops/sec
LOREM_RE.test(lorem); 5251233.5 Ops/sec
lorem.startsWith("R"); 13303179.0 Ops/sec
lorem.indexOf("R") === 0; 13416243.0 Ops/sec
ROLEM_RE.test(lorem); 5810327.5 Ops/sec
lorem && lorem[0] === "L"; 6586505.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";