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
168.3M/s
string .startsWith()
64.0M/s
regexp .test()
47.2M/s
string .match()
30.9M/s
View exact numbers
Test name Executions per second
indexOf === 0 168,315,696 Ops/sec
string .startsWith() 64,029,344 Ops/sec
regexp .test() 47,237,144 Ops/sec
string .match() 30,865,226 Ops/sec
Script Preparation code:
Tests: