What is the difference between indexOf() and search()?

后端 未结 8 1998
情歌与酒
情歌与酒 2020-12-04 07:11

Being fairly new to JavaScript, I\'m unable to discern when to use each of these.

Can anyone help clarify this for me?

8条回答
  •  情话喂你
    2020-12-04 07:38

    If you require a regular expression, use search(). Otherwise, indexOf() is going to be faster.

提交回复
热议问题