Javascript – the difference between indexOf() and search()

javascriptstring

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

Can anyone help clarify this for me?

Best Solution

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