Saturday 12 January 2019

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



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




Can anyone help clarify this for me?


Answer



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


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...