DEV Community

Discussion on: Shorten your if statements using the '&&' operator

Collapse
 
toktoktwan profile image
Twan Mulder

Why is it ugly?

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️ • Edited

&& and || are not meant as control-flow syntax but as operators, so using them for the former will confuse people and just look weird. It aso provides no real benefit when compared to either

iAmHungry? bakeAnEgg() : 0

or

if (iAmHungry) bakeAnEgg();
Thread Thread
 
toktoktwan profile image
Twan Mulder

Thanks for the detailed response! This is definitely a good case against using '&&' as an operator.