indexOf
IndexOf is a method name commonly used in JavaScript to locate the position of a value or substring within a sequence. It is defined for both strings and arrays. The method returns the index of the first match, or -1 if no match is found. An optional fromIndex parameter specifies the starting position for the search.
For arrays, indexOf(searchElement[, fromIndex]) searches from fromIndex (default 0) and returns the first index where searchElement
For strings, indexOf(searchValue[, fromIndex]) searches for the first occurrence of the substring searchValue starting at fromIndex
Common uses include checking presence (for example, indexOf(...) !== -1) and locating positions for substring or element