<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>
Original Length =2
New Length =4
CC++JavaPHP