Create an array using the Object() constructor : Introduction : Array JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Array » Introduction »

 

Create an array using the Object() constructor









A new object is created using the Object() constructor.

Elements the are assigned to the object using the [] operators.

The programmer is responsible for keeping the length of the array.












<html>
<SCRIPT LANGUAGE="JavaScript">
<!--
    var myArray = Object();
    myArray.length=3;   //array position zero
    myArray[1]="A";
    myArray[2]="B";
    myArray[3]="C";

    document.write("The myArray holds:  ");

    for(x=1; x<=myArray.length; x++) {
      document.write(myArray[x],"  ");
    }
-->
</SCRIPT>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Array
» Introduction