implement search javascript code example
Example 1: search in javascript
str.indexOf("locate");
str.lastIndexOf("locate");
str.indexOf("locate", 15);
str.search("locate");
Example 2: search in javascript
var str = "Please locate where 'locate' occurs!";
var ind1 = str.indexOf("locate");
var ind2 = str.lastIndexOf("locate");
var ind3 = str.indexOf("locate", 15);
var ind4 = str.search("locate");
document.write("<br>" + "Length of string:", len);
document.write("<br>" + "indexOf:", ind1);
document.write("<br>" + "index of last:", ind2);
document.write("<br>" + "indexOf with start point:", ind3);
document.write("<br>" + "search:", ind4);