Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardJavaScriptWeakRef and FinalizationRegistrySingle-choice MCQ

When does a FinalizationRegistry callback get a chance to run relative to garbage collection, and what guarantees does the spec provide about it?

const reg = new FinalizationRegistry((held) => { console.log('cleanup', held); }); (function () { let obj = {}; reg.register(obj, 'token-1'); })(); // obj is now unreachable