Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Regarding nested ternaries, while not recommended, short circuit evaluations may be even more readable:

return ( (cA && cB && "A & B") || (cA && "A") || (cB && "B") || "neither" );



Quick, it's another case of Javsacript Stockholm Syndrome!


:-)

However, this would also work in Perl, etc, (anything featuring short-circuit evaluation and type coercion for evaluating conditions.)




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

Search: