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
154.4M/s
string .startsWith()
57.3M/s
regexp .test()
42.2M/s
string .match()
27.3M/s
View exact numbers
Test name Executions per second
indexOf === 0 154,414,976 Ops/sec
string .startsWith() 57,292,432 Ops/sec
regexp .test() 42,212,292 Ops/sec
string .match() 27,285,392 Ops/sec
Script Preparation code:
Tests: