Array slice

Array slice

The slice() method returns a shallow copy of a portion of an array into a new array object selected from beginning to end (end not included). The original array will not be modified.

//              0         1        2          3 
var animal = ['Tiger','Rabbit','Elephant','Peigon']; 
var animal_slice = animal.slice(1,3); 
document.write(animal); 
document.write('<br/>'); 
document.write(animal_slice);

Output
Tiger,Rabbit,Elephant,Pigeon
Rabbit, Elephant

code