Is there destructor in typeScript

前端 未结 2 1661
盖世英雄少女心
盖世英雄少女心 2021-01-01 08:31

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

2条回答
  •  爱一瞬间的悲伤
    2021-01-01 08:43

    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.

提交回复
热议问题