
They are −įunction − The function is used to execute on all the elements of the array until the constraint is satisfied and then returned true.Įlement − This is the current element in the array which undergoes the given functionality or the constraint in the given array. The method ‘findIndex()’ will take five parameters including the function. The syntax given above is called as inline callback function syntax as the function and also the other parameters are called in one line at once. The syntax of the findIndex() method is − array.findIndex(function(element, index, array), thisArg) If no element is present with the given constraint or condition then, it returns -1.

This method will return the index of the first element in the given array even if there are two or more numbers.

The ‘findIndex()’ method in JavaScript arrays will return the first element from the given array with the given constraint being satisfied. In this tutorial a functionality of array object ‘findIndex()’ is explained and demonstrated with some examples. In JavaScript, Arrays are objects and these objects have some inbuilt functions and properties by which one can do the operations faster and easier.

For example, if array is declared as integer data type then it stores one or more elements of the integer data type. Array is a data type which can store multiple elements of similar data types.
