JavaScript·Intermediate·Conceptual·1 min read
How does JavaScript garbage collection decide what to reclaim?
Short interview answer
Modern collectors primarily determine reachability from roots such as active execution state and host references. Objects that cannot be reached are eligible for collection even if they participate in cycles. Collection timing is intentionally nondeterministic.
Key takeaway
Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.