Mega Code Archive

 
Categories / JavaScript Tutorial / Array
 

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>