JavaScript Array findLast() Method Last Updated : 17 Nov, 2024 Comments Improve Suggest changes Like Article Like Report 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. JavaScript const a = [1, 3, 5, 7, 6, 8]; const b = a.findLast(num => num % 2 === 0); console.log(b); Output : 8Example 2: This example shows how findLast() can be used to find the last string in an array that has more than 3 characters. JavaScript const a = ['cat', 'dog', 'elephant', 'lion']; const b = a.findLast(word => word.length > 3); console.log(b); Output:'elephant'Syntax : array.findLast(callback(element[, index[, array]])[, thisArg]);callback: A function to test each element, receiving the current element, index, and array.thisArg (optional): A value to use as this when executing callback.JavaScript Array findLast() Method - FAQsWhat is findLast in JavaScript?The findLast() method returns the last element in an array that satisfies a provided testing function.How to get the last of an array in JavaScript?Use array.findLast(callback) to retrieve the last element matching a specific condition.What arguments does findLast take in JavaScript?The findLast() method takes a callback function that checks each element and an optional thisArg to set the this value in the callback.How to use findLastIndex in JavaScript?findLastIndex() returns the index of the last element that satisfies a given testing function, or -1 if none is found.How to check if the last element of an array matches a condition?Use array.findLast(callback) to see if the last matching element in the array meets a specific condition. Comment More infoAdvertise with us Next Article JavaScript Array findLast() Method A anujpaz9pe Follow Improve Article Tags : JavaScript Web Technologies javascript-array Similar Reads JavaScript Array findLastIndex() Method 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 f 2 min read JavaScript Array lastIndexOf() Method The JavaScript Array lastIndexOf() Method is used to find the index of the last occurrence of the search element provided as the argument to the function.Syntax: array.lastIndexOf(element, start)Parameters: This method accepts two parameters as mentioned above and described below: element: This para 3 min read JavaScript TypedArray.prototype.findLast() Method A new method, TypedArray.prototype.findLast(), was introduced in ECMAScript 2023 (ES2023). The method findLast() of instances TypedArray proceeds traverse over the typed array backwards and provides method returning the value of the first element that satisfies the supplied testing function. When th 2 min read TypeScript Array lastIndexOf() Method The Array.prototype.lastIndexOf() method in TypeScript is used to find the last index at which a given element can be found in the array, searching backwards from the fromIndex. It returns the index of the found element, or -1 if the element is not present.Syntax:array.lastIndexOf(searchElement[, fr 2 min read Javascript Program for Last duplicate element in a sorted array We have a sorted array with duplicate elements and we have to find the index of last duplicate element and print index of it and also print the duplicate element. If no such element found print a message. Examples: Input : arr[] = {1, 5, 5, 6, 6, 7}Output :Last index: 4Last duplicate item: 6Input : 3 min read JavaScript Program to Find kth Largest/Smallest Element in an Array JavaScript allows us to find kth largest/smallest element in an array. We are given an array containing some elements, we have to find kth smallest/largest element from the array where k is a number greater than zero and less than equal to the total number of elements present in the array. There are 5 min read JavaScript Program to find the Nth smallest/largest element from an unsorted Array In this article, we will see how to find Nth largest and smallest element from an unsorted array. The Nth smallest/largest element from an unsorted array refers to the element that ranks at the Nth position when the array is sorted either in ascending (smallest) or descending (largest) order. It rep 4 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 for the Minimum Index of a Repeating Element in an Array Given an array of integers arr[], The task is to find the index of the first repeating element in it i.e. the element that occurs more than once and whose index of the first occurrence is the smallest. In this article, we will find the minimum index of a repeating element in an array in JavaScript.E 5 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 Like