...it was bound to happen, I'm writing a technology-related post...
Conditional coding is the backbone of all programming - but the manner in which you code a conditional statement can vary drastically, especially depending on it's application.
Traditionally, IF statements are used. IF statements are, by nature, simple, but of course any programming task can grow out of control easily. Thus, SWITCH blocks and CASE statements come in. But these are all topics that have been thrown around for years, in most every programming language in existence.
Just recently, I found a new method to approach conditional assignments/function calls. In the form of:
[Conditional Expression]&&([Command [, Command...]])[||([Command [, Command...]])]
The conditional expression can be most anything that you would put in an IF statement, but the entire syntax after that is completely different. Using two ampersands, you can specify multiple expressions to be evaluated for the TRUE condition. The set of commands should reside within two brackets, and each command seperated by a comma.
The FALSE condition is dignified using double pipes. Following that, as with the TRUE condition, you can specify multiple commands to be executed when the conditional expression is FALSE. Again, these commands should reside within two brackets, and each command seperated by a comma.
In example, try the following:
bVal && (str = "The boolean value was TRUE", document.write(str))||(str = "The boolean value was FALSE",document.write(str));
If bVal was a BOOLEAN and set to TRUE, the string "The boolean value was TRUE" would be assigned to a variable and that variable would get printed to the document. Otherwise, the string "The boolean value was FALSE" would be assigned to a variable and that variable would get printed to the document.
This concept basically combines both the traditional IF statement as well as the conditional value statements.