JavaScript Array slice()
JavaScript Array slice()
The slice() method is used to return selected elements in an array, as a new array. This method is used to select from a given start, up to a given end. However, it does not change the original array.
Syntax:-
Its syntax is:- array.slice(start, end)
Return:-
Its return is:- a new array containing the selected elements.
Further Explanation:-
Parameter | Description |
start | Optional. Start position. Default is 0. |
end | Optional. End position. Default is the last element. |