JavaScript Array method: slice()
[this page | pdf | back links]
The slice() method (when applied to a JavaScript
array) selects
a part of an array and returns that part.
It
has the following syntax with the following parameters. It returns a new
array containing the selected elements.
array.slice(start, end)
|
Parameter
|
Required / Optional
|
Description
|
|
start
|
Optional
|
An integer specifying
where to start the selection. Negative numbers are treated as selecting from
the end of the array. Default is zero
|
|
end
|
Optional
|
An integer that
specifies where to end the selection. Negative numbers are treated as
selecting from the end of the array. Default is to select from start
to the end of the array
|
NAVIGATION LINKS
Contents | Prev | Next | JavaScript Arrays