I agree with @tux0r
on this one. Ternary statements are awesome for showing off fancy JS skills, but in practicality, they're very hard on the eyes.
To add to the madness, you can chain ternary statements together ad nauseum. At that point, it's less about fanciness and more about "just because you can, doesn't mean you should."
To tux0r's point, if you're reading the code in your head as if condition, then expression, why not write it out as such?
Since ternaries push you to use expressions, it makes your code less about control flow (if this, do that, else do something else) and more about "given this and that, send this value back".
It's very easy to write a lot of code in the if/else that should have been written as a set of functions acting one after the other to transform the data.
Of course if you've got small functions and aren't doing much within your if/else, it'll help long term maintainability.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I agree with @tux0r on this one. Ternary statements are awesome for showing off fancy JS skills, but in practicality, they're very hard on the eyes.
To add to the madness, you can chain ternary statements together ad nauseum. At that point, it's less about fanciness and more about "just because you can, doesn't mean you should."
To tux0r's point, if you're reading the code in your head as if condition, then expression, why not write it out as such?
Since ternaries push you to use expressions, it makes your code less about control flow (if this, do that, else do something else) and more about "given this and that, send this value back".
It's very easy to write a lot of code in the if/else that should have been written as a set of functions acting one after the other to transform the data.
Of course if you've got small functions and aren't doing much within your if/else, it'll help long term maintainability.