JavaScript indexof method
The indexOf() method returns the position of the first occurrence of a specified value in a string.
This method returns -1 if no match found.
The JavaScript indexOf() method is case sensitive.
Syntax:
string.indexOf(searchvalue,start)
where,
searchvalue =Required. The string to search for
start =Optional. Default 0. At which position to start the search
Example:
var str=”This is JavaScript indexOf() Method”;
var n=str.indexOf(“indexOf()”);
alert(n); // OUTPUT: 19
Live Demo: JavaScript indexOf Method