Array.find_last_index
Array.find_last_index
Function
Returns from right to left the index of the first element for which the callback result is true.
Syntax
array.find_last_index(callback)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| callback | Fn | No | Empty | The callback signature is fn(value, index, current). |
Return value
| Type | Description |
|---|---|
| Int | Returns the subscript if found; returns -1 if not found. |
Example
items = [1, 2, 3, 4] result = items.find_last_index(fn(value) { value < 4 }) // Output: 2 print result
Notes
- Search from right to left.