How to dispose JavaScript objects

Everyday we work with resources in our programs — editing files, fetching records from databases, and more. We open a resource, do the necessary work, and then close it. When we miss that final step, we end up with files inaccessible to other processes, locked database connections, or an unexpectedly large cloud bill. To ensure we deterministically clean up the resources, even when an error…