Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Chrome 138
Mac OS X 10.15.7
Desktop
one year ago
Benchmark.js
indexOf === 0
162.5M/s
string .startsWith()
68.1M/s
regexp .test()
51.5M/s
string .match()
31.2M/s
View exact numbers
Test name Executions per second
indexOf === 0 162,506,384 Ops/sec
string .startsWith() 68,122,312 Ops/sec
regexp .test() 51,547,988 Ops/sec
string .match() 31,154,328 Ops/sec
Script Preparation code:
Tests: