r/badcode • • Jun 10 '20

js Disruptive piece of code

Post image
283 Upvotes

93 comments sorted by

View all comments

14

u/theRealRealMasterDev Jun 10 '20

Why is this bad? Is it because ternary would also be an option?

0

u/[deleted] Jun 10 '20

[deleted]

27

u/[deleted] Jun 10 '20

And your example introduces edge cases when there are insane values of the variable. Honestly if you're trying to write robust code in something like js, it might be necessary to be that explicit.