StartIndex tells that from where to start the selection and should be a number and it is must in the slice() method. EndIndex tells the ending position for selection and it is optional. If EndIndex is not provided into the slice() method then slice() selects all the elements from the starting index position. It does not modify the length of the array. Here into this example code we have created an array of length five and we have applied slice() method to familiarize you with some cases.
Full example code is as follows:
var arr = new Array(5);
document.write("<b>Original Array is </b>=>"+arr+"<br>");
document.write("<b>Array is </b>=>"+arr+"<br>");
Example of implementing slice() method on array
Liked it! Share this Tutorial