if I have an constructor for an object, for example:
function cat(color, sex){
this.color = color;
this.sex = sex;
}
and I make some cats:
var fluffball = new cat("blue","male");
var shiznitz = new cat("red","male");
var slothersburger = new cat("green","female");
Can I skip all the cats that I announced? Sort of:
var current_cat;
for(current_cat in document.cat){
alert(current_cat.color);
}
This does not work. Do people usually store all cat objects in an array? Or create another object containing an array of individual cats:
function all_cats(){
this.the_cats = new Array();
}
Thanks for any tips!
Ralph lauren
source
share