Javascript slice() Method - Array Function
How to select a part of an array?
What is the use of slice() function in javascript?
Explanation
Method:
slice() This function is used to select a part of an array. The resultant new array contains the element specified by the first argument and all the subsequent elements but not including the element specified by the second argument.
Syntax:array1.slice(firstargument,secondargument);
Example Code for this method:
<script language="javascript">
var name = ["john", "peter","samuels","joseph","marry"];
var subarray = name.slice(1,3);
document.write(subarray);
</script>
Result:
To Select a part of an array, this function is used and the result is displayed.