Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Chrome 126
Mac OS X 10.15.7
Desktop
2 years ago
Benchmark.js
indexOf === 0
27.1M/s
string .startsWith()
20.1M/s
regexp .test()
18.1M/s
string .match()
15.7M/s
View exact numbers
Test name Executions per second
indexOf === 0 27,136,432 Ops/sec
string .startsWith() 20,144,950 Ops/sec
regexp .test() 18,066,180 Ops/sec
string .match() 15,685,257 Ops/sec
Script Preparation code:
Tests: