Calls when a class or object is about to be garbage collected or manually destroyed, like destructors in C++. For there's garbage collection in JavaScript, users should be able to control whether the class should be destroyed when exiting the scope or not.
This could greatly reduce the chance of memory leaking in JavaScript. Adds with defer
, we could achieve a very primitive memory management method in JavaScript.