Advanced memory management: weak references and cleanup callbacks (ES2021).
Solution Code
JavaScript
const weakRef = new WeakRef(obj);
new FinalizationRegistry(key => {
// Cleanup
}).register(obj, 'key');
Explanation
Handle carefully to avoid memory leaks. Not for typical application code.Guided Hints
GC unpredictability
Use cases