MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/npcroh/clever/h05odkh/?context=3
r/badcode • u/bobpiranha • May 31 '21
71 comments sorted by
View all comments
242
Now I am actually curious, does the compiler realize both branches have the same return value and it just drops the whole if-statement?
100 u/[deleted] May 31 '21 Depends on whether or not the compiler is smart enough to realize that evaluating the conditional has no side-effects. Not sure what language this is 73 u/givemeagoodun May 31 '21 edited Jun 01 '21 It's flaired JS so it's JS 1 u/NikkoTheGreeko Jun 01 '21 Js confirmed. This returns NaN. Or undefined. Or [object Object], I forget.
100
Depends on whether or not the compiler is smart enough to realize that evaluating the conditional has no side-effects. Not sure what language this is
73 u/givemeagoodun May 31 '21 edited Jun 01 '21 It's flaired JS so it's JS 1 u/NikkoTheGreeko Jun 01 '21 Js confirmed. This returns NaN. Or undefined. Or [object Object], I forget.
73
It's flaired JS so it's JS
1 u/NikkoTheGreeko Jun 01 '21 Js confirmed. This returns NaN. Or undefined. Or [object Object], I forget.
1
Js confirmed. This returns NaN. Or undefined. Or [object Object], I forget.
242
u/HalcyonAlps May 31 '21
Now I am actually curious, does the compiler realize both branches have the same return value and it just drops the whole if-statement?