Is there destructor in typeScript

Gábor Lupák picture Gábor Lupák · Mar 5, 2015 · Viewed 43.6k times · Source

Is there destructor in TypeScript? If not, how can I delete an object? I tried destructor() and ~ClassName() but it didn't work.

Answer

Ryan Cavanaugh picture Ryan Cavanaugh · Mar 5, 2015

JavaScript uses garbage collection to automatically delete objects when they are no longer referenced. There is no concept of destructors or finalizers.

You can't observe when an object is deleted by the garbage collector, nor is it predictable.