Let’s say I have some class called loopObject and I initialize every object through something like var apple = new loopObject(); Is there anyway to loop through all objects of a class so that some function can be performed with each object as a parameter? If there isn’t a direct method, is there a way to place each new object into an array upon initialization?
Let’s say I have some class called loopObject and I initialize every object through
Share
You can make an array that contains every instance, like this:
However, it will leak memory – your instances will never go out of scope.