List.slice
slice($index, $numItems=0) -> list
Description
Get a slice of items, starting at $index
.
If $index
is negative, it counts from the end of the list (the last item is at -1
).
If $numItems
is 0, return all remaining items after $index
.
['a', 'b', 'c', 'd'].slice(1) //= ['b', 'c', 'd'] $list = ['a', 'b', 'c', 'd'] $list.slice($list.lastIndex(2)) ['a', 'b', 'c', 'd'].slice(-2) //= ['c', 'd'] ['a', 'b', 'c', 'd'].slice(1, 2) //= ['b', 'c']