Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
indexOf(value, fromIndex);
value
The value to locate in the array.
fromIndex optional
The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
["tea", "coffee", "juice"].indexOf("coffee")
1
["tea", "coffee", "juice"].indexOf("milk")
-1
// returns the first found index
["tea", "coffee", "coffee", "coffee", "juice"].indexOf("coffee")
1
// compare to lastIndexOf:
["tea", "coffee", "coffee", "coffee", "juice"].lastIndexOf("coffee")
3
An index or -1 if the element was not found.