1. Definition and usage
The indexOf () method returns the first occurrence of a specified string value in the string, that is, the subscript.
If no matching string is found, -1 is returned.
grammar:
string.indexOf(searchvalue,start)
parameter:
searchvalue: Specifies the string value to be retrieved.
start: Specifies the position (subscript) to start searching in the character string
Note: The indexOf () method is case sensitive.
Examples:
var str = 'abbc' console.log(str.indexOf('b'))
Output: