JavaScript String Method : search()

The search() method is used to search a specific value in a string. It returns the position of searched value. And if the match would not found on the string then it will return -1. The syntax is :"value to search")
Example :
    var mystr = "This is test String For search Function.";
    document.write(mystr, "<br/>");
    document.write("Search For 'test' : ",'test'));
    document.write("Search For 'Function' : ",'Function'));
Output :

Where the position of "test" starts from 8 and the position of "Function" starts from 31.

Next Topic :