FinalizationRegistry() constructor

The FinalizationRegistry constructor creates a FinalizationRegistry object that uses the given callback.

Syntax

// Arrow callback function
new FinalizationRegistry((heldValue) => { /* … */ } )

// Callback function
new FinalizationRegistry(callbackFn)

// Inline callback function
new FinalizationRegistry(function(heldValue) { /* … */ })

Parameters

callback

The callback function this registry should use.

Examples

Creating a new registry

You create the registry passing in the callback:

const registry = new FinalizationRegistry((heldValue) => {
  // …
});

Specifications

Specification
ECMAScript Language Specification
# sec-finalization-registry-constructor

Browser compatibility

BCD tables only load in the browser

See also