Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36
Chrome 140
Mac OS X 10.15.7
Desktop
one year ago
Benchmark.js
indexOf === 0
179.9M/s
string .startsWith()
74.5M/s
regexp .test()
56.0M/s
string .match()
33.3M/s
View exact numbers
Test name Executions per second
indexOf === 0 179,919,056 Ops/sec
string .startsWith() 74,463,776 Ops/sec
regexp .test() 55,991,040 Ops/sec
string .match() 33,260,128 Ops/sec
Script Preparation code:
Tests: