Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Chrome 122
Mac OS X 10.15.7
Desktop
2 years ago
Benchmark.js
indexOf === 0
29.2M/s
string .startsWith()
21.5M/s
regexp .test()
18.0M/s
string .match()
15.5M/s
View exact numbers
Test name Executions per second
indexOf === 0 29,191,828 Ops/sec
string .startsWith() 21,547,492 Ops/sec
regexp .test() 18,025,538 Ops/sec
string .match() 15,535,658 Ops/sec
Script Preparation code:
Tests: