[removed] indexOf vs. Match when Searching Strings?

前端 未结 9 1586
感情败类
感情败类 2020-12-04 13:16

Readability aside, are there any discernable differences (performance perhaps) between using

str.indexOf("src") 

and



        
9条回答
  •  醉话见心
    2020-12-04 13:20

    Performance wise indexOf will at the very least be slightly faster than match. It all comes down to the specific implementation. When deciding which to use ask yourself the following question:

    Will an integer index suffice or do I need the functionality of a RegExp match result?

提交回复
热议问题