indexof method in html code example
Example 1: javascript indexof
var colors=["red","green","blue"];
var pos=colors.indexOf("blue");
var str = "We got a poop cleanup on isle 4.";
var strPos = str.indexOf("poop");
Example 2: indexof javascript
Array.indexOf(searchElement, fromIndex)
Example 3: indexof 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);