The lodash _.indexOf() method is used to get the index of first occurrence of the particular element in the array. If fromIndex is not present in the array 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.
Parameters: This method accepts three parameters as mention above and describe below.
- array: It is the array in which value is to be found.
- value: It is the value to be looked in the array.
- fromIndex: It is the index after which we have to look for the value.
Return Value: It returns the index of the value in the array. If the value is not found, the array returned -1.
Example 2: Looking for a value from particular index.
- Node.js | Buffer.indexOf() Method
- TypeScript | String indexOf() Method
- TypeScript | Array indexOf() Method
- Difference Between indexOf and findIndex function of array
- Node.js | indexOf() function
- Underscore.js | _.indexOf()
- Lodash _.method() Method
- Lodash _.sneq() Method
- Lodash _.toQuery() Method
- Lodash _.uniqWith() Method
- Lodash _.xorWith() Method
- Lodash | _.head() Method
- Lodash | _.remove() Method
- Lodash | _.pullAt() Method
- Lodash | _.pullAll() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.