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"); 17394056.0 Ops/sec
lorem.indexOf("L") === 0; 17807458.0 Ops/sec
LOREM_RE.test(lorem); 7268043.0 Ops/sec
lorem.startsWith("R"); 17433742.0 Ops/sec
lorem.indexOf("R") === 0; 17619260.0 Ops/sec
ROLEM_RE.test(lorem); 7321127.0 Ops/sec
lorem && lorem[0] === "L"; 8729970.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";