Skip to content

Could you not finally?

Dimitar Nestorov on July 08, 2017

Do you know of any way to skip the execution of a finally block? function fn(){ try{ return 1; }finally{ console.log(2); ... [Read Full]
markdown guide

The point of finally is to run after a try...catch block no matter what happens. From the MDN

Note that the finally clause executes regardless of whether or not an exception is thrown. Also, if an exception is thrown, the statements in the finally clause execute even if no catch clause handles the exception. You can use the finally clause to make your script fail gracefully when an exception occurs; for example, to do general cleanup, you may need to release a resource that your script has tied up.


Short of killing the process, calling another function within try{..}, or doing a while(true) within try{...}, the finally block will execute, period.

code of conduct - report abuse