r/badcode • • May 31 '21

js Clever?

Post image
2.2k Upvotes

71 comments sorted by

View all comments

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?

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.