In it's simple use, the ternary operator is rather helping than hindering the reading flow, as illustrated by the example:
// w/o ternary operator:
let result;
if (condition) {
result = CONDITION_MET;
} else {
result = CONDITION_NOT_MET;
}
// w/ ternary operator:
const result = condition ? CONDITION_MET : CONDITION_NOT_MET;
However, in golfed or minified code, one usually finds abominable abuses of the ternary operator within already complicated statements that reduce readability. Only use them there, never the code you work on.
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.
In it's simple use, the ternary operator is rather helping than hindering the reading flow, as illustrated by the example:
However, in golfed or minified code, one usually finds abominable abuses of the ternary operator within already complicated statements that reduce readability. Only use them there, never the code you work on.