Skip to main content

ArraySlice

Takes an array and returns a portion of it based on the Start and End index fields. The Start index is inclusive and the End index is exclusive, meaning the element at the Start position is included in the result, while the element at the End position is not.

Reference

Parameters

array

The array to slice.

Component data2-core-types@Getter

start

The inclusive start index of the slice.

Component data2-core-primitives@Number

end

The exclusive end index of the slice.

Component data2-core-primitives@Number

Example

Input

[1, 2, 3, 4, 5]

Start: 1

End: 4

Output:

[2, 3, 4]

Note: Both Start and End fields are optional. However, if either field is active but left empty, it will default to 0. This means an empty Start will slice from the beginning of the array, and an empty End will return an empty array, since index 0 is exclusive on the End field.