Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道在 javascript 中通常认为最好的做法是始终将new函数分配给变量,即使它没有被使用。但是关于 node.js 中的垃圾收集,v8 是否能够对未分配给变量的函数进行 GC,或者没有区别?
new
只要对变量(匿名或赋值)的所有引用都已被销毁(在这种情况下,通过释放包含函数)v8 应该垃圾收集它。