JavaScript Array findLastIndex() Method Last Updated : 22 Mar, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The Javascript findLastIndex() method is used to find the index of the last element in an array that matches the specified condition. It works by iterating over the array from the end to the beginning and returning the index of the first element that satisfies the condition specified in a callback function. If no element matches the condition, the method returns -1. This method is useful when you need to find the last occurrence of a specific value in an array. Syntax: array.findLastIndex( element ); Parameters: This method accepts a single parameter that is described below: element: This parameter holds the current element. Return Value: The index of the last (highest-index) element in the array that passes the test. Otherwise, -1 if no matching element is found. Example 1: JavaScript // Declare an array const arr1 = [1, 45, 69, 84]; // Declare an array const arr2 = [9, -2, 6.8]; // Declare a function called that // takes an element as a parameter // and returns true if the element // is greater than 19 const isLargeNumber = (element) => element > 19; // Call the findLastIndex method on // the arr1 array and pass in the // isLargeNumber function as a parameter console.log(arr1.findLastIndex(isLargeNumber)); // Call the findLastIndex method on // the arr2 array and pass in the // isLargeNumber function as a parameter console.log(arr2.findLastIndex(isLargeNumber)); Output: 3 -1 Example 2: JavaScript const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; const isEven = (num) => num % 2 === 0; const lastIndex = arr.findLastIndex(isEven); console.log(lastIndex); // Output: 9 Output 9 Supported Browsers: Google Chrome 97Edge 97Firefox 104 Apple Safari 15.4Opera 83 Comment More infoAdvertise with us Next Article JavaScript Array findLastIndex() Method I impetus Follow Improve Article Tags : JavaScript Web Technologies javascript-array JavaScript-Methods Similar Reads JavaScript Array findLast() Method The JavaScript findLast() method is used to retrieve the last element in an array that meets a specified condition.Example 1: This example shows how findLast() can be used to find the last even number in an array.JavaScriptconst a = [1, 3, 5, 7, 6, 8]; const b = a.findLast(num => num % 2 === 0); 2 min read JavaScript typedArray.lastIndexOf() Method The typedArray.lastIndexOf() is an inbuilt function in JavaScript which is used to return the last index of the typedArray at which a given element is present otherwise it returns -1 if the element is not present. Syntax: typedArray.lastIndexOf(search_Element, from_Index]) Parameters: It accepts two 2 min read JavaScript Program to find the Index of Last Occurrence of Target Element in Sorted Array In this article, we will see the JavaScript program to get the last occurrence of a number in a sorted array. We have the following methods to get the last occurrence of a given number in the sorted array. Methods to Find the Index of the Last Occurrence of the Target Element in the Sorted ArrayUsin 4 min read Java Guava | Longs.lastIndexOf() method with Examples The lastIndexOf() method of Longs Class in Guava library is used to find the last index of the given long value in a long array. This long value to be searched and the long array in which it is to be searched, both are passed as a parameter to this method. It returns an integer value which is the la 3 min read Ints lastIndexOf() function | Guava | Java Guava's Ints.lastIndexOf() returns the index of the last appearance of the value target in array. Syntax: public static int lastIndexOf(int[] array, int target) Parameters: array: An array of int values, possibly empty. target: A primitive int value. Return Value: The Ints.indexOf() method returns t 2 min read Like