I used to create instances of my JavaScript "classes" using the new keyword and call the constructor like: new myStuff.DoSomething(); in order to get an instance of it. Sometimes when needed I give the instance a reference like: var myObj = new myStuff.DoSomething();
I come to think about the memory management: does JS clean up the objects without references when they aren't used anymore? - the same way it would clean up those with references. And what about all event handlers in a killed object, do they still live on?
Example: If I create, for instance, a draggable window using the new keyword and no reference to the object and then attach event handlers and so on. Then I decide to delete the window from the DOM. How can I make sure the actual object is removed as well?
null, only a reference. If there is no reference to an instance, there is nothing to set tonull.