To copy part of an array:
arr.slice([begin, end)arr.slice(begin)It returns a new array filled with items from arr.
begin is 0-based index of the first item.
end is 0-based index of the last item
If only begin is given, slice copies everything until the end of array
If end is negative it becomes end = arr.length + end i.e. -1 would leave off last element of array, -2 last 2 elements etc.
if end is ≤ begin, returns an empty array.