Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
Chrome 81
Windows
Desktop
3 years ago
Test name Executions per second
lorem.startsWith("L"); 9442128.0 Ops/sec
lorem.indexOf("L") === 0; 9640685.0 Ops/sec
LOREM_RE.test(lorem); 3758079.2 Ops/sec
lorem.startsWith("R"); 8744947.0 Ops/sec
lorem.indexOf("R") === 0; 9584319.0 Ops/sec
ROLEM_RE.test(lorem); 3980680.5 Ops/sec
lorem && lorem[0] === "L"; 4604494.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";