![]() |
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:
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
Output: 3 -1 Example 2: Javascript
Output 9 Supported Browsers:
|
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |