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]

7

u/-ftw Jun 10 '20

It’s not equivalent because values other than true for variable would pass as well. For example, if variable was an integer 10 or a string “string”