0

I'm creating a project in which multiple classes are being utilized and I want to make sure that no excessive garbage memory is being collected

now from this answer, it says

Since Javascript is garbage collected, you don't need to delete objects themselves - they will be removed when there is no way to refer to them anymore.

I've written a pseudo code which resembles my problem

class person{
 constructor(name){
  this.name=name;
 }
 
 work(){
  //does work
 }
};

while(true){
 let someone= new person(variable_name);
 someone.work();
}

I know the example is a bit vague but what I want to know is that since we're reinitializing someone again and again does it accumulate junk data? or since it loses reference, the previous ones are being deleted?

I want to make sure this doesn't have a long time memory junk issue with heavier projects

0 Answers0