Junior
From PDF
JavaScript
JavaScript
What is garbage collection?
Garbage collection automatically frees memory that’s no longer referenced.
The V8 engine uses the mark-and-sweep algorithm:
- “Mark” reachable objects from the root.
- “Sweep” and delete unreachable ones.
Example:
let user = { name: "John" };
user = null; // eligible for garbage collectionShare this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png