FinalizationRegistry() constructor
The FinalizationRegistry()
constructor creates FinalizationRegistry
objects.
Syntax
Parameters
callback
-
A function to be invoked each time a registered target value is garbage collected. Its return value is ignored. The function is called with the following arguments:
heldValue
-
The value that was passed to the second parameter of the
register()
method when thetarget
object was registered.
Examples
Creating a new registry
You create the registry passing in the callback:
js
const registry = new FinalizationRegistry((heldValue) => {
// …
});
Specifications
Specification |
---|
ECMAScript Language Specification # sec-finalization-registry-constructor |
Browser compatibility
BCD tables only load in the browser