January 2018
Intermediate to advanced
332 pages
7h 36m
English
It is always suggested to keep your code readable but, when warranted, use the ternary operators to make your code concise and readable:
if(cond1) { var1 = val1;} else { var1 = val2}if(cond2) { var2 = val3;} else { var2 = val4}
For example, the preceding code can be condensed as follows:
var1 = cond1 ? val1 : val2;var2 = cond2 ? val3 : val4;
Setting default values can also be achieved easily as follows:
var1 = ifThisVarIsFalsy || setThisValue;var2 = ifThisVarIsTruthy && setThisValue;
Read now
Unlock full access