JavaScript Array Method : shift()

The shift() method is used to removes the first element from an array and return that element. The syntax is as follows :
  array.shift();
Example :
<script>
  var webdev = ["HTML", "CSS", "Javascript", "MySql", "PHP"];
  document.write(webdev + "<br/>");
  var mystr = webdev.shift();
  document.write("Removed element is : " + mystr + "<br/>");
  document.write("Array will be : " + webdev);
</script>
Output :


Next Topic :