Syntax
array.slice(start)
array.slice(start, stop)
The slice() method returns a new array that contains the elements of the original array starting at position start and ending at the element position before stop.
If no stop position is specified, the new array will contain the elements of the original array, starting at the position stated in start through the end of the array.
Negative numbers start to count from the last element to the first.
For example, -1 is the last element in the array, and -2 is the second to the last element in the array.
The stop parameter can be negative.
<html>
<script language="JavaScript">
<!--
numArray = new Array(3,2,5,9);
document.write("numArray contains the numbers: ",numArray.join(', '),"<br>");
newNumArray = numArray.slice(1,3);
document.write("newNumArray contains the numbers: ",newNumArray.join(', '),"<br>");
-->
</script>
</html>