Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Chrome 136
Mac OS X 10.15.7
Desktop
one year ago
Benchmark.js
indexOf === 0
193.1M/s
string .startsWith()
74.0M/s
regexp .test()
52.8M/s
string .match()
32.4M/s
View exact numbers
Test name Executions per second
indexOf === 0 193,080,368 Ops/sec
string .startsWith() 74,010,664 Ops/sec
regexp .test() 52,806,616 Ops/sec
string .match() 32,363,100 Ops/sec
Script Preparation code:
Tests: