The indexof method in JavaScript is used to search a string from the given input string. I returns the position of the first occurrence of the specified string in the input string. If the value is not found , it returns -1 . Also note that the indexof method is case sensitive.
How to Search for a String using JavaScript indexof method ?
Below is a sample code snippet demonstrating how to search for a string using js indexof method.
var input = "This is a Ginktage.com blog post."; var value = str.indexOf("Ginktage.com");
The result of value will be 10.