Changing Elements of an Arrary



Write a JavaScript code to add implement in Arrary using splice method.

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

        var a =new Array();

        a[0]="C";
        a[1]="C++";

        document.write("Original Length =" + a.length + "<br>");
        a.splice(2,0,"Java","PHP");

        document.write("New Length =" + a.length + "<br>");

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

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

Output:

Original Length =2
New Length =4
CC++JavaPHP