const string = "Hello world";
const regExp = /^Hello/;
regExp.test(string)
string.match(regExp)
string.startsWith('Hello');
console.log('')
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
test | |
match | |
startsWith | |
s |
Test name | Executions per second |
---|---|
test | 43720644.0 Ops/sec |
match | 25005682.0 Ops/sec |
startsWith | 67088988.0 Ops/sec |
s | 433286.9 Ops/sec |