arrayIncludes

The arrayIncludes task determines whether an array includes a given element and returns true or false as appropriate. When used with a fromIndex value, you can specify where in the array the search should begin.

Potential use case

Suppose you have a list of email addresses and want to check whether a certain address is in that list. Specify the address you’re looking for — if it is present, the result is true; if not found, the result is false.

Properties

IncomingTypeDescription
arrArrayRequired. The array to search.
searchElementAnyRequired. The element to search for.
fromIndexNumberOptional. The position in the array to begin searching for searchElement. Default is 0.
OutgoingTypeDescription
resultBooleantrue if the searchElement is found within the array; false otherwise.

Example

In this example:

  • The array is statically set to ["1","2","3"].
  • The searchElement to find is the number 2.
  • The fromIndex defaults to 0.
  • The result is true because 2 is present in the array.
arrayIncludes task configured to search for 2 in the array