Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
Chrome 124
Windows
Desktop
2 years ago
Benchmark.js
indexOf === 0
29.8M/s
string .startsWith()
21.1M/s
regexp .test()
20.7M/s
string .match()
18.0M/s
View exact numbers
Test name Executions per second
indexOf === 0 29,756,392 Ops/sec
string .startsWith() 21,134,664 Ops/sec
regexp .test() 20,656,694 Ops/sec
string .match() 17,978,218 Ops/sec
Script Preparation code:
Tests: