JavaScript FinalizationRegistry Methods

Beginner
4 min read
Updated: Nov 2026
2 method guides
Method index

About This Index

This page is the JavaScript FinalizationRegistry Methods index. A FinalizationRegistry has two methods. Each row below links to a full guide with syntax, examples you can run, and FAQs.

Learn what a FinalizationRegistry is on /js/finalization-registry. Use this page when you need a specific method such as register().

Both methods are called on a registry.

First create one with new FinalizationRegistry(callback). Then call registry.register() to start watching an object and registry.unregister() to stop.

How to Call a FinalizationRegistry Method

Create a registry, then call the methods on it:

JavaScript
const registry = new FinalizationRegistry((heldValue) => {
  console.log("Cleaned up: " + heldValue);
});

const item = { name: "report" };
const token = {};

registry.register(item, "report", token);   // start watching

console.log(registry.unregister(token));    // true  (stop watching)
console.log(registry.unregister(token));    // false (already removed)

JavaScript FinalizationRegistry Methods Table

All method guides in this JavaScript tutorial series (2 tutorials), grouped by what they do.

Start watching an object

1 method

Tell the registry which object to watch and what to remember about it.

MethodDescriptionTutorial
register()Watch an object, choose the held value for the callback, and add an optional unregister token.Open

Stop watching

1 method

Cancel registrations you no longer need.

MethodDescriptionTutorial
unregister()Remove every registration made with a token. Returns true if something was removed, false if not.Open

Frequently Asked Questions

Two: register() starts watching an object, and unregister() cancels registrations made with a token. You create the registry with new FinalizationRegistry(callback), and the callback is the function JavaScript may call after a watched object is collected.
The FinalizationRegistry page explains the idea: garbage collection, the cleanup callback and how it compares with WeakRef. This index lists the method guides so you can jump straight to register() or unregister().
No. Both are instance methods. You call them on a registry object that you created with new, as in registry.register(obj, "id"), and not on FinalizationRegistry itself.
No, it is optional. Call it only when you have already cleaned something up yourself and do not want the callback to repeat the work. To use it later, pass an unregister token as the third argument of register().
Start with register(), because every registry needs it. Then read unregister() to learn how tokens work. If you want the big picture first, read the FinalizationRegistry page.

Start with register()

Open the guide for watching an object with a registry: syntax, examples, and FAQs.

register() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful