Reputation: 115
I want to call dispose method on every object in javascript when all it's references are removed, if the method exits in that object. How do I do it?
Upvotes: 0
Views: 498
Reputation: 727
Low-level languages, like C, have low-level memory management primitives like malloc() and free() . JavaScript values are allocated when things (objects, strings, etc.) are created and "automatically" freed when they are not used anymore.
There is no dispose method in javascript, but you can use the delete
operator to delete a property from an object as long as the property is configurable.
Upvotes: 2