lastIndexOf
arrayThis method is like indexOf except that it iterates over elements of array from right to left.
Signature
lastIndexOf<T>(array: T[], value: T, fromIndex?: number): numberParameters
| Name | Type | Description |
|---|---|---|
array | T[] | The array to inspect |
value | T | The value to search for |
fromIndex? | number | The index to search from |
Returns
number - Returns the index of the matched value, else -1
Examples
Basic usage
import { lastIndexOf } from 'dashlite'
const result = lastIndexOf([1, 2, 1, 2], 2)
console.log(result)Output:
3Available since version 1.0.0