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
155.4M/s
string .startsWith()
59.1M/s
regexp .test()
43.2M/s
string .match()
28.5M/s
View exact numbers
Test name Executions per second
indexOf === 0 155,358,736 Ops/sec
string .startsWith() 59,078,020 Ops/sec
regexp .test() 43,223,664 Ops/sec
string .match() 28,475,830 Ops/sec
Script Preparation code:
Tests: