Index In List
Uncontrolled node
Overview
The Index In List node searches for a specific value within an array and returns its position. It uses strict equality comparison (similar to JavaScript's indexOf method) to locate the first occurrence of the value in the list.
If the value is found, the node outputs its zero-based index and a found flag set to true. If the value is not present in the list, it outputs -1 for the index and false for the found flag.
This node pairs well with the Get Value node to retrieve items by index, or with If nodes to branch logic based on whether an item exists in a list.
Inputs
| Input | Type | Description | Default |
|---|---|---|---|
| List | Array | The list or array to search through. | - |
| Value | Any | The value to search for in the list. Uses strict equality comparison. | - |
Outputs
| Output | Type | Description |
|---|---|---|
| Output | Number | The zero-based index of the value in the list. Returns -1 if the value is not found or if the input is not a valid array. |
| Found | Boolean | true if the value exists in the list (index >= 0), false otherwise. |
Runtime Behavior and Defaults
- Uncontrolled: This node runs automatically whenever its inputs change. It does not require an event trigger.
- Empty Lists: If the input list is empty or not a valid array, the node returns
-1for the index andfalseforfound. - First Match Only: If multiple items in the list match the value, only the index of the first occurrence is returned.
- Strict Equality: The comparison uses strict equality (
===), meaning type and value must match exactly.
Example Usage
Scenario: Check if a user's email exists in a list of approved emails and get its position.
-
Connect a List node (or any node outputting an array) to the List input.
-
Connect a Text node containing the email to search for to the Value input.
-
The node will automatically output:
- If found:
output=2(for example),found=true - If not found:
output=-1,found=false
- If found:
-
Connect the Found output to an If node to branch your workflow based on whether the email exists in the list.