4 ms·
Huh, interesting. The code supplied is: try { return true; } finally { return false; } Which returns false. I guess this is because of the guarantee that the
by notauser 17y ago
Huh, interesting. The code supplied is:
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'.)
- pkulak 17y agoI 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.