arrayLastIndexOf
The arrayLastIndexOf task searches an array and returns the last index (position) at which a given element is found. The task returns -1 if the element is not present. The array is searched backwards beginning at the fromIndex position. The returned index value is always relative to the beginning of the array — the first element is at index 0, the second at 1, and so on. The original array is not modified.
Potential use case
Use this task to find the last occurrence of a particular element in an array. For example, to find the last time a particular email appeared in an email list, use arrayLastIndexOf to retrieve its most recent index. If the email is not present, the result is -1.
Properties
Example 1
In this example:
- The
arris statically set to["a","b","c","a","b","c"]. - The
searchElementis"b". fromIndexis not provided, so the entire array is searched.- The result is
index4— the last position of"b"in the array.

Example 2
In this example:
- The
arris[1,2,3,2,5,2,3,2]. - The
searchElementis2. - The
fromIndexis-2, which means the search starts two positions from the end. - The result is
index5— the last position of2within the search range.
