如果我使用 say 创建一个 String
对象,
var temp = new String('ABCD');
这是否为这个String
对象创建了一个内存空间,就像JavaScript中的Objects一样?如果是,我是否可以通过将此变量“temp”分配给 null 来释放此对象,即 temp = null
?
最佳答案
Does this creates a memory space for this String Object, like Objects in Javascript?
字符串对象是对象。
If yes, can I release this object just by assigning this variable 'temp' to null i.e. temp = null ?
垃圾收集工作正常。
关于Javascript:使用 new 创建字符串是否意味着我需要稍后发布它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5017434/