Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Chrome 128
Mac OS X 10.15.7
Desktop
2 years ago
Benchmark.js
indexOf === 0
36.5M/s
string .startsWith()
26.2M/s
regexp .test()
24.4M/s
string .match()
20.0M/s
View exact numbers
Test name Executions per second
indexOf === 0 36,477,456 Ops/sec
string .startsWith() 26,228,088 Ops/sec
regexp .test() 24,399,162 Ops/sec
string .match() 20,032,152 Ops/sec
Script Preparation code:
Tests: