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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s