Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Chrome 143
Mac OS X 10.15.7
Desktop
10 months ago
Benchmark.js
indexOf === 0
250.4M/s
string .startsWith()
93.6M/s
regexp .test()
81.9M/s
string .match()
48.6M/s
View exact numbers
Test name Executions per second
indexOf === 0 250,359,744 Ops/sec
string .startsWith() 93,625,504 Ops/sec
regexp .test() 81,914,960 Ops/sec
string .match() 48,623,404 Ops/sec
Script Preparation code:
Tests: