Re:Nerd Sniping: What does the code do at the end of the page?
by pkulak on Tuesday November 24, 2009 @06:27PM
(#960192)
I see it that the "finally" is run right before the return. So, the statement "true" would be evaluated, then control would go to the "finally" block, where the method would return false.
try { return true; } finally { return false; }
Which returns false. I guess this is because of the guarantee that the finally block will be run, no matter what. The JS interpreter must be catching the return and holding it pending the execution of the finally block.
Checking with
try { return true; } finally { alert('hi'); }
Shows this to be true. (It both returns true AND alerts 'hi'.)