JavaScript · Senior · Question 11 of 75

Why are you advised to be careful with WeakRef and FinalizationRegistry?

Explanation

An object behind a WeakRef can disappear at any moment or live longer than expected, and a finalization callback may never be called. They're appropriate for caches and as a safety net, but not for mandatory resource cleanup.

Further reading

Problem with a question

JavaScript · Senior · question 11

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