Script Preparation code:
Tests:

Historical Performance Data aggregated from 100 community runs

Desktop Results:
Chrome 81 runs
indexOf === 0
27.7M/s
string .startsWith()
20.8M/s
regexp .test()
18.0M/s
string .match()
15.1M/s

Fastest: indexOf === 0 (1.8x faster)

View exact numbers
  • indexOf === 0: 27,733,116 ops/sec
  • string .startsWith(): 20,758,642 ops/sec
  • regexp .test(): 18,033,082 ops/sec
  • string .match(): 15,057,943 ops/sec
Firefox 12 runs
string .startsWith()
1241.5M/s
indexOf === 0
1192.8M/s
regexp .test()
37.9M/s
string .match()
19.0M/s

Fastest: string .startsWith() (65.3x faster)

View exact numbers
  • string .startsWith(): 1,241,519,616 ops/sec
  • indexOf === 0: 1,192,801,024 ops/sec
  • regexp .test(): 37,859,568 ops/sec
  • string .match(): 19,008,640 ops/sec
Safari 7 runs
indexOf === 0
30.3M/s
regexp .test()
26.3M/s
string .startsWith()
21.8M/s
string .match()
17.8M/s

Fastest: indexOf === 0 (1.7x faster)

View exact numbers
  • indexOf === 0: 30,282,676 ops/sec
  • regexp .test(): 26,339,190 ops/sec
  • string .startsWith(): 21,756,602 ops/sec
  • string .match(): 17,803,916 ops/sec

Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    regexp .test()
    string .match()
    indexOf === 0
    string .startsWith()

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 10 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Chrome 143 on Mac OS X 10.15.7
View result in a separate tab
indexOf === 0
250.4M/s
string .startsWith()
93.6M/s
regexp .test()
81.9M/s
string .match()
48.6M/s
View exact numbers
Test name Executions per second
indexOf === 0 250,359,744 Ops/sec
string .startsWith() 93,625,504 Ops/sec
regexp .test() 81,914,960 Ops/sec
string .match() 48,623,404 Ops/sec