Node Timeout timers have a private boolean attribute called _destroyed. It
tells you if the function has been cleared:
timer._destroyed;
One way to make it true it is to let the function be called:
> const timer = setTimeout(() => {
| console.log("Done!");
| }, 5000);
> timer._destroyed
false // Alive
> Done! // Function is called
> timer._destroyed // Destroyed 💥
true
Another is to call clearTimeout:
> const timer = setTimeout(() => {
| console.log("We'll destroy before this is called!");
| }, 5000);
> clearTimeout(timer) // Destroying the timer
undefined
> timer._destroyed // Destroyed! 💥
true