3 ms·
> There's also no such thing as garbage collection in JavaScript. Incorrect. The details of garbage collection are left to the implementation, but the spec its
by packetlost 2y ago
> There's also no such thing as garbage collection in JavaScript.
Incorrect. The details of garbage collection are left to the implementation, but the spec itself at least implies that GC is expected of implementations [0]. The current spec has an entire section on memory management [1] with several constructs for garbage collection and many explicit references to GC.
That being said, it would be more correct to say this implementation of JavaScript does not perform capture analysis, effectively creating partial scopes.
[0]: https://262.ecma-international.org/7.0/#sec-weakmap-objects https://262.ecma-international.org/7.0/#sec-weakmap-objects
[1]: https://tc39.es/ecma262/#sec-managing-memory https://tc39.es/ecma262/#sec-managing-memory
- munificent 2y agoAh, weak references are a good point. Even so, you can have an entirely conforming JavaScript implementation with no GC. It just means that WeakRefs and WeakMaps will always continue to hold their references.