Adding an Array Element using Unshift Method



Write a JavaScript code to add elements in array using unshift method of array.

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

          var a =new Array();
              a[0]="Java";

              document.write("Original Length =" + a.length + "<br>");
              a.unshift("C","C++","VB");

              document.write("New Length after unshift method =" + a.length + "<br>");
              for(var i=0;i<a.length;i++)
              {
                  document.write(a[i]);
              }
              
      </script>
    </head>
  <body>       
</body>
</html>

Output:

Original Length =1
New Length after unshift method =4
CC++VBJava