I never thought about garbage collection, and I don’t know whether to take into account when creating small javascript games / applications. Any advice is appreciated, but I will ask my specific question at the end.
Many times I write code of this form:
var foos=new Array();
generateFoos();
function generateFoos()
{
foos=[];
for (fooIndex=0;fooIndex<numberOfFoos;fooIndex++)
{
foos[fooIndex]=new foo(Math.random(),Math.random());
}
}
function foo(bar,bas)
{
this.bar=bar;
this.bas=bas;
}
So my question is: when I say foos=[](line 5), does it delete objects from this array from memory or floats somewhere, making the program larger and slower? What if I want to call generateFoos()loooot once, for example, every time the user presses a key.
Thank!
source
share