slice
arrayCreates a slice of array from start up to, but not including, end.
Signature
slice<T>(array: T[], start?: number, end?: number): T[]Parameters
| Name | Type | Description |
|---|---|---|
array | T[] | The array to slice |
start? | number | The start positionDefault: 0 |
end? | number | The end position |
Returns
T[] - Returns the slice of array
Examples
Basic usage
import { slice } from 'dashlite'
const result = slice([1, 2, 3], 0, 2)
console.log(result)Output:
[1, 2]Available since version 1.0.0