Note:- This string method returns -1 if the value to search is not found in the given string.
The basic syntax of js string indexOf() method is:
str.indexOf( search_value, start)
Result of the above code is:-8
Now we take a second example with a specific position. Let you have one string like above. And you want to find string or characters in a given string with a specific position. Let’s see the below-given example:
Result of the above code is:-44