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

后端 未结 8 2006
情歌与酒
情歌与酒 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:25

    I think the main difference is that search accept regular expressions.

    Check this reference:

    • search
    • indexOf

提交回复
热议问题