JavaScript · Senior · Question 9 of 75

What conditions guarantee that the garbage collector will remove an object?

Explanation

Modern engines use mark-and-sweep: everything reachable from the roots is alive. Circular references between unreachable objects don't prevent their removal - unlike reference counting. The timing of collection is unspecified.

Further reading

Problem with a question

JavaScript · Senior · question 9

Test yourself

Take the JavaScript · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz