Hacker News new | past | comments | ask | show | jobs | submit login

Ternary operators are better for expressions, which yield a result, since you don't have to declare or initialize a variable with a dummy value first. If/else is better for general branching. Using ternary without assigning or passing the expression would imho be misleading. I've seen ternaries used for branching and it's a smell imho, they're not really meant for that use case.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: