Javascript – remove first item from array

Javascript code to remove first item from array using arr.shift()

Remove first item from array

<script type="text/javascript">
var arr = ["v1", "v2", "v3"];
var firstitem = arr.shift();
arr.forEach (function(item, idx) {
  document.write("idx=" + idx + " item=" + item  + "<br/>");
});
</script>
refresh
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments