6 ms·
Finally blocks ensure code executes even on exception. In the second example hideLoadSpinner will never get called if you hit the catch block
by slackingoff2017 9y ago
Finally blocks ensure code executes even on exception. In the second example hideLoadSpinner will never get called if you hit the catch block
- Rusky 9y agoThat's wrong- if the catch block runs without throwing any exceptions of its own then hideLoadSpinner will be called.
- GroSacASacs 9y agoincorrect try { throw new Error("catch me !"); // force try to fail } catch (catchedError) { console.log("inside catch"); // throw new Error("hmm"); } finally { // always executed console.log("inside finally"); } // always executed console.log("after try catch finally"); the finally statement can be useful when another error is thrown inside the catch block, in which case you have more serious problems in your code