Why would you avoid the else clause in an if statement or default clause in a switch statement?
In java, this is much cleaner (checking if a String is "true" or not):
String abc;
...
if ("true".equals(abc)){
// if true
} else {
// if false
}
than this:
Boolean abc;
....
if (abc != null){
if (abc.eqals("true"){
// if true
return;
}
if (!abc.equals("true"){
// if false
return;
}
}
if (abc == null){
// handle like false
return
}
In javascript it would be much messier since javascript has null and undefined, so you'd have to check for undefined first, then null, then for the value you're looking for and then for the value you're not looking for ... or you could have just used an else, saved yourself a lot of code.
Assembler on every platform that I know of supports if and else, so you're not gaining anything by not using it and on those CPUs where it's not supported, it's fairly easy to push a variable into a register based on the result of the condition and then simply executing it as two if statements, on with condition and one with not condition.
The ife directive is used exactly like the if directive, except it assembles the code after the ife directive only if the expression evaluates to zero (false), rather than true (non-zero).
@Jan, in NodeJS if you need to test against null and undefined, you are really doing something wrong ... misinterpretation of functional paradigm leads to such cases. I have no such code in my financial solution at all. Please, do not want to see Java or any other imperative language reflecting in JS code.