Skip to main content

List: Slice

Return a contiguous sub-list of an input list between Start (inclusive) and End (exclusive). Bounds are clamped to the input length, so a Start at or past the end of the list yields an empty result rather than failing. However, if Start is greater than End after clamping, the step fails. Mirrors JavaScript's Array.prototype.slice otherwise.

Example
Start: 1, End: 4
Input: [10, 20, 30, 40, 50]
Output: [20, 30, 40]

Parameters

Start

0-based start index, inclusive. Defaults to 0.

End

0-based end index, exclusive. Leave empty to slice to the end of the array. Indices past the end are clamped.

Input

Arrayrequired

List to slice (Array or JSON array).

Output

Result
The sliced sub-list.