I have a suspicion that I’m using the finally block incorrectly, and that I don’t understand the fundamentals of its purpose…
function myFunc() { try { if (true) { throw 'An error'; } } catch (e) { alert (e); return false; } finally { return true; } }
This function will run the catch block, alert ‘An error’, but then return true. Why doesn’t it return false?
The
finallyblock will always run, try returningtrueafter yourtryblock