JavaScript String indexOf()
JavaScript String indexOf()
The indexOf() method is used to return the position of the first occurrence of a specified value in a string. If the value is not present then it will return -1. This method is case-sensitive.
Syntax:-
Its syntax is:- string.indexOf(searchvalue, start)
Return:-
Its return is:- the first position where the search-value occurs else -1 if it is absent
Further Explanation:-
Parameter | Description |
searchvalue | Required. The string to search for. |
start | Optional. The position to start from. |