use of indexof in javascript code example
Example 1: javascript indexof
//indexOf getting index of array element, returns -1 if not found
var colors=["red","green","blue"];
var pos=colors.indexOf("blue");//2
//indexOf getting index of sub string, returns -1 if not found
var str = "We got a poop cleanup on isle 4.";
var strPos = str.indexOf("poop");//9
Example 2: indexof javascript
Array.indexOf(searchElement, fromIndex)
Example 3: .index of javascript
let monTableau = ['un', 'deux','trois', 'quatre'] ;
console.log(monTableau.indexOf('trois')) ;
Example 4: indexof
String1.indexOf(index2);