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 collection

More from JavaScript Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details