Skip to main content

Slice Node

Slice Node Screenshot

Overview

The Slice Node is used to extract a portion of an array. It takes an array as input and outputs a new array that starts at a specified index and contains a specified number of elements.

This node is useful for manipulating arrays, such as extracting a subset of data from a larger dataset.

Inputs

TitleData TypeDescriptionDefault ValueNotes
Inputany[]The array to be sliced.(required)The input will be coerced into an array if it is not an array.
StartnumberThe index at which to start the slice.0The input will be coerced into a number if it is not a number.
CountnumberThe number of elements to include in the slice. If not provided, all elements will be included.(all)The input will be coerced into a number if it is not a number. This input is optional.

Example 1: Slice an array

  1. Create an Array Node and set the values to [1, 2, 3, 4, 5].
  2. Create a Slice Node and set the Start to 2 and the Count to 2.
  3. Connect the Array Node to the Input of the Slice Node.
  4. Run the graph. The Output of the Slice Node should be [3, 4].

Slice Node Example 1

Error Handling

The Slice Node will error if the Input is not provided or is not an array. It will also error if the Start or Count is not a number.

FAQ

Q: What happens if the Start is greater than the length of the array?

A: The Slice Node will return an empty array.

Q: What happens if the Count is greater than the number of elements in the array?

A: The Slice Node will return all elements from the Start to the end of the array.

Q: Can I use negative numbers for the Start and Count?

A: Yes, you can use negative numbers for the Start to count from the end of the array. However, using a negative number for the Count will result in an error.

See Also