Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Chrome 120
Mac OS X 10.15.7
Desktop
2 years ago
Benchmark.js
indexOf === 0
16.5M/s
string .startsWith()
11.3M/s
regexp .test()
10.5M/s
string .match()
8.5M/s
View exact numbers
Test name Executions per second
indexOf === 0 16,450,135 Ops/sec
string .startsWith() 11,257,309 Ops/sec
regexp .test() 10,548,401 Ops/sec
string .match() 8,499,234 Ops/sec
Script Preparation code:
Tests: