FinalizationRegistry() constructor

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

Syntax

new FinalizationRegistry([callback]);

Parameters

callback Optional
The callback function this registry should use. If provided, this must be a function.

Examples

Creating a new registry

You create the registry passing in the callback:

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

Specifications

Specification
WeakRefs
The definition of 'FinalizationRegistry constructor' in that specification.

Browser compatibility

DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
FinalizationRegistry() constructorChrome Full support 84Edge Full support 84Firefox Full support 79IE No support NoOpera No support NoSafari No support NoWebView Android Full support 84Chrome Android Full support 84Firefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs Full support 13.0.0
Disabled
Full support 13.0.0
Disabled
Disabled From version 13.0.0: this feature is behind the --harmony-weak-refs runtime flag.

Legend

Full support
Full support
No support
No support
User must explicitly enable this feature.
User must explicitly enable this feature.

See also