arrayIndexOf
The arrayIndexOf task returns the first index (position) at which a given element can be found in the array. The task returns -1 if the element is not found.
Potential use case
Suppose you have a list of email addresses and want to determine if an email record is listed in the correct department. The arrayIndexOf task checks whether the email exists and returns the index position where it occurs. If the email is not found, it returns -1.
Properties
Example
In this example:
- The
arrvariable is statically set to["Apple","Pear","Banana"]. - The
searchElementisBanana. - The
fromIndexdefaults to0. - The
indexresult returns2, indicating thatBananais at index position two in the array.
Array indexing is zero-based: the first element is at position 0, the second at 1, and so on.
