Run details:
Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36
Chrome 110
Chrome OS 14541.0.0
Desktop
one year ago
Test name Executions per second
RegEx.test 1984022.5 Ops/sec
String.includes 7989341.5 Ops/sec
String.match 1709255.2 Ops/sec
== 8037095.0 Ops/sec
=== known length 8017722.5 Ops/sec
Script Preparation code:
AخA
 
var string = "Hello world!";
var regex = /Hello/;
Tests:
  • RegEx.test

     
    regex.test(string);
  • String.includes

     
    string.includes("Hello");
  • String.match

     
    string.match("Hello");
  • ==

     
    "Hello" == string.slice(0, "Hello".length);
  • === known length

     
    string.slice(0, 5) === "Hello"
  • startsWith

     
    string.startsWith("Hello")