11 Nov
2011
11 Nov
'11
14:37
1 function test() 2 { 3 var a = 1; 4 try { 5 throw "exception"; 6 } catch (e) 7 { 8 print("catch"); 9 return a; 10 } finally 11 { 12 a = 2; 13 print("finally a = " + a); 14 } 15 16 print("end"); 17 }; 18 19 print("test = " + test()); Output: catch finally a = 2 test = 1 This time, the fun part is that the value of 'a' at 9 is bound before the finally block is executed, although the actual return from the function is done after the execution of the finally block. I am not extremely familiar with exception systems so this might be standard behavior. It means however that the meaning of return depends on the presence or absence of a finally block. Erick