Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Chrome 128
Linux
Desktop
2 years ago
Benchmark.js
indexOf === 0
20.4M/s
string .startsWith()
13.9M/s
regexp .test()
11.2M/s
string .match()
10.0M/s
View exact numbers
Test name Executions per second
indexOf === 0 20,369,040 Ops/sec
string .startsWith() 13,935,344 Ops/sec
regexp .test() 11,212,427 Ops/sec
string .match() 10,035,113 Ops/sec
Script Preparation code:
Tests: