Array findindex() Method
This method returns the index of the first element in a given array that satisfies the provided testing function. Otherwise, -1 is returned.
Example:
Here is an example of the basic use of the Array.findindex() method.
javascript
let array = [10, 20, 30, 110, 60]; function finding_index(element) { return element > 25; } console.log(array .findIndex(finding_index) ); |
2
Best-Known JavaScript Array Methods
An array is a special variable in all the languages that are used to store different elements. JavaScript array contains some built-in properties that every JavaScript developer should know how to use and when or where to use them. We can use them to add, remove, iterate, or manipulate data as per our requirements.