Know What’s in Your Array

, ,

The indexOf() method returns the first index of where a user given element is found in an array or it returns -1. This method has 1 required parameter and 1 optional parameter. The required parameter is the lookup value and the optional one is start index. The lookup value is the element you are trying to find. The start index is where you want to start looking for the lookup value.

 

Below shows some examples of how the indexOf() method works.