+ 15

I adore JS😀👍

function fu_n_ck() { try { return "I'm lost..."; } finally { return "HaHa!"; } }; fu_n_ck(); // "HaHa!" Overwritten return statement?! Please, explain inner logic.

14th Jan 2018, 9:00 PM
\__(° = °)__/
2 odpowiedzi
+ 4
if the finally block returns a value, this value becomes the return value of the entire try-catch-finally production, regardless of any return statements in the try and catch blocks. it's a peculiarity of JS... other programming languages ​​doesn't allow return in the finally block.
14th Jan 2018, 11:23 PM
AtoMX
AtoMX - avatar
- 1
lol...I love J.S ...its an amazing and free lan
15th Jan 2018, 10:35 AM
Android Boi
Android Boi - avatar