Slice List
Uncontrolled node
Overview
The Slice List node extracts a portion of an array (list) using start and end indices. It behaves like JavaScript's Array.prototype.slice() method, returning a shallow copy of the selected elements from the original list without modifying it.
The node is useful for pagination, batch processing, or extracting specific ranges of data from larger datasets.
Inputs
| Input | Type | Description | Default |
|---|---|---|---|
| list | Data (Array) | The array to slice. If not an array or empty, returns an empty string. | - |
| start | Number | The zero-based index at which to begin extraction (inclusive). If omitted or invalid, defaults to 0. | 0 |
| end | Number | The zero-based index at which to end extraction (exclusive). If omitted or invalid, defaults to the length of the list. | list.length |
Outputs
| Output | Type | Description |
|---|---|---|
| output | Data (Array) | A new array containing the extracted elements from start (inclusive) to end (exclusive). |
Runtime Behavior and Defaults
- Uncontrolled Operation: This node runs automatically when its inputs change; it does not require an event trigger.
- Index Handling:
- If
startis not a valid number, it defaults to0. - If
endis not a valid number, it defaults to the length of the input list. - Both indices are floored to integers (e.g.,
1.7becomes1).
- If
- Edge Cases:
- If the input
listis not an array or is empty, the output is an empty string. - If
startis greater thanend, the output is an empty array. - Negative indices are supported (e.g.,
-1refers to the last element), following standard JavaScript slice behavior.
- If the input
- Immutability: The original input list is not modified; a new array is returned.
Example
To extract the first three elements from a list of items:
- Connect your list (e.g.,
[10, 20, 30, 40, 50]) to the list input. - Set start to
0(or leave empty to default to 0). - Set end to
3.
The output will contain [10, 20, 30].
To get elements from index 2 to the end of the list:
- Set start to
2 - Leave end empty (defaults to list length)
For a list ["a", "b", "c", "d"], this returns ["c", "d"].