在typeScript中是否有析构函数 [英] Is there destructor in typeScript

查看:1378
本文介绍了在typeScript中是否有析构函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TypeScript中是否有析构函数?如果没有,我该如何删除对象?
我试过析构函数() ~ClassName()但它没有用。

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

推荐答案

JavaScript使用垃圾收集在不再引用对象时自动删除对象。没有析构函数或终结符的概念。

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.

这篇关于在typeScript中是否有析构函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆