The slice() method extracts a substring and returns a new string.
The syntax for slice() method is
string.slice( firstindex [, endindex] );
firstindex : -The zero-based index at which to begin extraction.
endindex : -The zero-based index at which to end extraction. If omitted, slice extracts to the end of the string.
Here is the example code :
var ar = [1, 2, 3, 4, 5];
var ar2 = ar.slice(1, 1 + 3);
console.log(ar2);
It will give the following output:
2,3,4
0 Comment(s)