TypeScript | String indexOf() Method
The indexOf() is an inbuilt function in TypeScript which is used to get the index within the calling String object of the first occurrence of the specified value.
Parameter: This method accepts two parameter as mentioned above and described below .
- searchValue: This parameter is a string representing the value to search for.
- fromIndex: This parameter is a location within the calling string to start the search from.
Return Value: This method returns the index of the found occurrence, otherwise -1 if not found.
Below example illustrate the String indexOf() method in TypeScriptJS: