JavaScript String Method : indexOf(str)

The indexOf() method returns the index position of the first occurrence of given value in a string. The syntax would be :
Example :
    var mystr = "This is the Test String for the indexOf() method.";
    var pos = mystr.indexOf("the"); 
    document.write("Position of 'The' is : ", pos);
Output :

If the provided value is not found then it will return -1.

Next Topic :