JavaScript Array Method : pop()

The pop() method is used to remove the last element from an array and also it returns that element. The syntax is as follows :
  array.pop();
Example :
<script>
  var myarray = [100, 200, 300, 400, 500];
  document.write("Array : "+ myarray + "<br/>");
  var myvar = myarray.pop();
  document.write("The poped element is : " + myvar + "<br/>");
  document.write("Array : "+ myarray);
</script>
Output :



Next Topic :