When called from a String object, this method returns the index of the first occurance of the specified searchValue argument, starting from the specified fromIndex argument.
If the searchValue is not found, a value of -1 is returned. Characters in the string are indexed from left to right with the first character indexed as 0 and the last as String.length-1. This method is case sensitive.
myString = new String("DevGuru.com")
document.writeln(myString.indexOf("Guru"))
document.writeln("<br>" + myString.indexOf("com"))
document.writeln("<br>" + myString.indexOf("Com"))
3
8
-1
This example code uses the indexOf method to find the index values of three different character strings within the myString object. Note that the third example returns -1 because the case of one of the characters does not match.