![]() |
VOOZH | about |
lodash _.indexOf() method is used to get the index of the first occurrence of the particular element in the array. If fromIndex is absent in the array, a negative one is given as the output and no error is displayed.
indexOf(array, value, fromIndex);Note: If the value is not found in the array -1 is returned.
Example 1: In this example, we are getting the index at which the given value is present in the given array.
Output:
👁 ImageExample 2: In this example, we are getting -1 as the index becuase the given value is not present after the given index in the given array.