The collection.lastIndexOf( ) method searches the toSearch expression among collection elements and returns the index of the last occurrence, or -1 if it was not found.
Note: This method does not modify the original collection.
In toSearch, pass the expression to find in the collection. You can pass:
- a scalar value (text, number, boolean, date),
- the null value,
- an object or a collection reference.
toSearch must match exactly the element to find (the same rules as for the equality operator are applied, see Comparison Operators).
Optionally, you can pass the index of collection from which to start a reverse search in startFrom.
- If startFrom >= the collection's length minus one (coll.length-1), the whole collection is searched (default).
- If startFrom < 0, it is recalculated as startFrom:=startFrom+length (it is considered as the offset from the end of the collection). If the calculated value is negative, -1 is returned (the collection is not searched).
Note: Even if startFrom is negative, the collection is still searched from right to left. - If startFrom = 0, -1 is returned, which means the collection is not searched.