if I have an object constructor like:
function cat(color, sex){
this.color = color;
this.sex = sex;
}
and I make some cats:
since i just had a similar problem, here's one easy solution if you use jquery
:
function Cat(color, sex){
this.color = color;
this.sex = sex;
}
var cats = [];
function createCat(color, sex)
{
cats.push(new Cat(color, sex)));
}
createCat("white", "male");
createCat("black", "female");
//iterating cats by using jQuery's $.each
$.each(cats, function(index, object){
alert(object.color);
});