![Findindex array javascript](https://cdn1.cdnme.se/5447227/9-3/14_64e61dfbddf2b36505b4c7c8.png)
![findindex array javascript findindex array javascript](https://i.stack.imgur.com/cLb05.png)
The downside of this method is it will work only on a single level array containing number or/and string value types.Ĭonst numbers = const itemIndex = numbers. start position: a numeric value specifying the index to start the search at.searched item: usually a number or a string.Unlike find() and findIndex() methods, indexOf() can take to parameters: The indexOf() method returns the first index at which a given element can be found in the array, or -1 if it is not present. Slow performance compared to other approaches.Ĭheck out MDN full docs on findIndex() method.īrowser support for findIndex(): () method browser support indexOf() method.
![findindex array javascript findindex array javascript](https://i.stack.imgur.com/VHAgE.png)
Ability to find an item if it is an object.Callback function allows to handle complex logic.Straightforward and easy to understand syntax.findIndex ( number => number = ' five ' ) console. Const numbers = const itemIndex = numbers.
![Findindex array javascript](https://cdn1.cdnme.se/5447227/9-3/14_64e61dfbddf2b36505b4c7c8.png)