Hello,
Now that I’ve started using P5js and therefore Javascript, I’m curious about how it works internally.![]()
So, an object in javascript is likely to be permanently erased from memory when there is nothing more that references it by the garbage collector.
Since there aren’t really any classes in JavaScript, when I use the keyword class, I necessarily create an object somewhere and when I “create an instance” with the keyword new, I create a new object with the constructor of the parent class (which is actually an object) and it reference the parent object that I defined with the class keyword (via its prototype,
__proto__ of the new object = the object created with the class keyword
Is that correct?
So, the funny question I ask myself is:
How does JavaScript make sure not to delete the objects created with the class keyword before I use them to create new objects with the new keyword (the pseudo instances)?
I suppose it’s referring to them somewhere so that the garbage collector doesn’t erase them???
N.B. I didn’t find the answer on internet … hum, I didn’t think to ask to an I.A. !!! I’ll try tomorrow !!!