" " indicates code.
I have created a javascript object by use of a function.
object function
"function myObject(attrib ute1, attribute2,etc) "
{
"this.attribute 1=attribute1"
"this.attribute 2=attribute2"
etc
}
I wish to put the object I create into an array, so I create the array
"myObjectArray= new Array()"
Then I say that I wish to fill the aray with objects
"myObjectArray= new(myObject)"
Then I create the instances
"myObjectAr ray[0]=new myObject(attrib ute1,attribute2 ,etc)"
"myObjectAr ray[1]=new myObject(attrib ute1,attribute2 ,etc)"
This all seems to work fine until I try and establish how many objects I
have by looking at the length of my myObjectArray.
"myObjectArray. length" returns as undefined.
What am I doing wrong?
Many thanks
Phil
I have created a javascript object by use of a function.
object function
"function myObject(attrib ute1, attribute2,etc) "
{
"this.attribute 1=attribute1"
"this.attribute 2=attribute2"
etc
}
I wish to put the object I create into an array, so I create the array
"myObjectArray= new Array()"
Then I say that I wish to fill the aray with objects
"myObjectArray= new(myObject)"
Then I create the instances
"myObjectAr ray[0]=new myObject(attrib ute1,attribute2 ,etc)"
"myObjectAr ray[1]=new myObject(attrib ute1,attribute2 ,etc)"
This all seems to work fine until I try and establish how many objects I
have by looking at the length of my myObjectArray.
"myObjectArray. length" returns as undefined.
What am I doing wrong?
Many thanks
Phil
Comment