slice
Modified on Fri, 18 Aug 2023
Description
Create a slice of `array` from `start` up to, but not including, `end`.
Syntax
slice(array, start, end)
Parameters
Input Parameter | Type | Description |
---|---|---|
array | Array | The array to slice. |
start | number | The start position. |
end (optional) | number | The end position. |
Return value
Type |
---|
Array<any> |
Sample
Example | Result | Description |
---|---|---|
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.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article