Array pop method and length property - Javascript Array

Javascript examples for Array:pop

Description

Array pop method and length property

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
var writeMessage = function (i) {
    return document.write("Element at " + (i + 1) + " popped-out with value " + array.pop() + ". Now, the array length is: " + array.length + "<br />");
};
var array = [50, 40, 30, 20, 10];
for (var i = 0; array.length > 0; i++) {
    writeMessage(i);
}

      </script> 
   </head> 
   <body>  
   </body>//from  ww  w  . j a v a 2 s  . co m
</html>

Related Tutorials