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
27.5M/s
string .startsWith()
18.5M/s
regexp .test()
17.0M/s
string .match()
14.4M/s
View exact numbers
Test name Executions per second
indexOf === 0 27,460,450 Ops/sec
string .startsWith() 18,510,248 Ops/sec
regexp .test() 17,003,754 Ops/sec
string .match() 14,403,021 Ops/sec
Script Preparation code:
Tests: