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 callbackFn(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 (ECMAScript)
# sec-finalization-registry-constructor

Browser compatibility

BCD tables only load in the browser

See also