Defining an Array Elements



Write a JavaScript code to create and print an element in Array.

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

        var a =new Array(3);

        a[0]="C";
        a[1]="C++";
        a[2]="Java";
        a[3]="VB";

        document.write("<br> Elements at 0th place =" + a[0]);
        document.write("<br> Elements at 1st place =" + a[1]);
        document.write("<br> Elements at 2nd place =" + a[2]);
        document.write("<br> Elements at 3rd place =" + a[3]);

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

Output:

Elements at 0th place =C
Elements at 1st place =C++
Elements at 2nd place =Java
Elements at 3rd place =VB