I have an object called foo:
function Foo(){
this.conceal = function(){ ... };
};
and a method called toggleView, which iterates through a collection of foo and calls conceal() method on each instance:
function toggleView(foos){
for(a in foos){
foos[a].conceal();
}
}
and, of course, foos[a].conceal(); returns: conceal is not a function
foosreally is an array, you should use a plainforloop with a numeric index, or else.forEach(), to iterate. However, what you've got should work unlessfoosis not what you say it is.Foo. Note thatfor..inloops aren't strictly limited to indexes. Related: Why is using “for…in” with array iteration a bad idea?newto create Foo instances?