Node.js · Senior · Question 8 of 75
What are WeakRef and FinalizationRegistry NOT good for?
- 1Caches that may drop entries when memory is needed
- 2Optional cleanup of native memory as a safety net
- ✓Correct answer: Releasing important resources such as file handles or DB connections at a predictable time
Explanation
Garbage collection timing is not guaranteed, and finalizers may never run. Release resources explicitly with close() or using/Symbol.dispose.