Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Chrome 131
Mac OS X 10.15.7
Desktop
one year ago
Benchmark.js
indexOf === 0
21.0M/s
string .startsWith()
17.9M/s
regexp .test()
15.9M/s
string .match()
14.1M/s
View exact numbers
Test name Executions per second
indexOf === 0 21,006,064 Ops/sec
string .startsWith() 17,855,594 Ops/sec
regexp .test() 15,886,631 Ops/sec
string .match() 14,138,513 Ops/sec
Script Preparation code:
Tests: