Array.prototype.slice
Array.prototype.slice
Array.prototype.slice is a method on an array instance which can be used to return a shallow copy of a selection of the array items.
It accepts two indexes as arguments, the starting point and the ending point.
The starting point is the index that the selection starts from including the start index item in the selection.
The end index argument is where the selection will terminate but does not include the end index item.
The end index argument is optional and if not provided then the method will take the last element in the array as the final item in the selection.
A negative number can be passed into the start index argument to work backwards in the array to start the selection from the end rather than the start.
If no arguments are provided then the method will return a shallow copy of the full array.