javascript - remove first element from array and return the the array minus the first element -


var myarray = ["item 1", "item 2", "item 3", "item 4"];    //removes first element of array, , returns element.  alert(myarray.shift());  //alerts "item 1"    //removes last element of array, , returns element.  alert(myarray.pop());  //alerts "item 4"

  1. how remove first array return array minus first element
  2. in example should "item 2", "item 3", "item 4" when remove first element

this should remove first element, , can return remaining:

var myarray = ["item 1", "item 2", "item 3", "item 4"];        myarray.shift();  alert(myarray);

as others have suggested, use slice(1);

var myarray = ["item 1", "item 2", "item 3", "item 4"];      alert(myarray.slice(1));


Comments

Popular posts from this blog

ssh - Vagrant Windows - ssh_exchange_identification: read: Connection reset by peer -

gcc - Neither ld wrap nor LD_PRELOAD working to intercept system call -

maven - jacoco coverage per test setup -