I made an HTML5 game that consists of many small levels. When the player get's to the doors, another level is loaded. When a level is loading it basically just sets all the instance arrays to []
and then pushes stuff into them, by creating new instances of things, for example:
enemies = [] //this has previously been full of pointers from the old level
for (i = 0; i < n_enemies; i ++)
enemies.push(new Enemy());
But, it has come to my attention that merely setting an array full of pointers to []
, doesn't actually delete the instances! So, does javascript do this automatically? Or do I have to delete
each instance myself?