Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Chrome 123
Mac OS X 10.15.7
Desktop
2 years ago
Benchmark.js
indexOf === 0
28.1M/s
string .startsWith()
20.9M/s
regexp .test()
17.9M/s
string .match()
15.3M/s
View exact numbers
Test name Executions per second
indexOf === 0 28,127,808 Ops/sec
string .startsWith() 20,856,030 Ops/sec
regexp .test() 17,893,088 Ops/sec
string .match() 15,306,924 Ops/sec
Script Preparation code:
Tests: