Description

Create a slice of `array` from `start` up to, but not including, `end`.

Syntax

slice(array, start, end)

Parameters

Input ParameterTypeDescription
arrayArrayThe array to slice.
startnumberThe start position.
end (optional)numberThe end position.

Return value

Type
Array<any>

Sample

ExampleResultDescription
slice([1, 2, 3, 4, 5], 1)[2, 3, 4, 5]Returns an array slice from 1st index to the last
slice([1, 2, 3, 4, 5], 1, 4)[2, 3, 4]Returns an array slice from 1st index to 4th index(not inclusive)

To view all the List functions, click here.

See Also