FinalizationRegistry

A JavaScript object that lets you register a callback to run some time after a given object has been garbage collected.

In more detail

You register an object with some held value, and the callback later receives that value. It is handy for diagnostics and releasing external resources, but callbacks may run late or never, so do not depend on them for correctness.

Related terms

Taught in

References