|
|
|
|
|
by klingonopera
2552 days ago
|
|
Is everyone preferring to state these on multiple lines? With the advent of the widescreen monitor, I find we have all the more reason today to use all that extra space. Using the example from the article, I'd refactor: const result = (!conditionA) ? ("Not A") : (conditionB ? "A & B" : "A");
or, since code should be simple to read: const result = (conditionA) ? (conditionB ? "A & B" : "A") : ("Not A");
All the parentheses' are redundant for the compiler or computer, but remind myself as a human that "const result" is not a direct statement, but a result of a conditional expression.EDIT: 2nd set of parentheses' in 2nd expression might not be redundant. |
|