Changing Elements of an Arrary



Write a JavaScript code to implement pop method of array.

<html>
  <head>
    <title>Array Demo</title>
      <script>

          var a =new Array();

              a[0]=5;
              a[1]=3;
              a[2]=4;
              a[3]=2;
              a[4]=1;

              document.write("Elements before pop...<br>");

              for(var i=0;i< a.length;i++)
              {
                  document.write(a[i] + "<br>");
              }
              a.pop();

              document.write("Elements after pop...<br>");
              for(var i=0;i< a.length;i++)
              {
                  document.write(a[i] + "<br>");
              }

      </script>
    </head>
  <body>       
</body>
</html>

Output:

Elements before pop...
5 3 4 2 1
Elements after pop...
5 3 4 2