JavaScript WeakRef & Finalization Registry Interview Questions – WeakRef & Finalization Registry In JavaScript Online Quiz

Question 1:  What is the main use of WeakRef in JavaScript?

Question 2:  Which method is used to get the referenced object from a WeakRef?

Question 3:  What happens if you call .deref() on a WeakRef whose object has been garbage collected?

Question 4:  Why is WeakRef generally avoided for normal data storage?

Question 5:  What does FinalizationRegistry help with?

Question 6:  Which method is used to register an object in FinalizationRegistry?

Question 7:  In FinalizationRegistry.register(object, heldValue), what is the purpose of heldValue?

Question 8:  Which of the following is TRUE about WeakRef?

Question 9:  Which of these is a valid way to create a WeakRef?

Question 10:  Which scenario is a good use case for FinalizationRegistry?

Leave a Reply