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

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -