Can i use operators like:
"wo" == ("man" || "wo");
Not for what you want that to do, no.
Purpose was to save the length of code with different values in condition...
The usual two approaches for dealing with testing against multiple values are switch
or a map, but as your condition is a compound of different properties and different logic operators, it's not going to buy you much.
Here's an example with switch
(and yes, in JavaScript, those case
statements are correct, JavaScript is not limited to constants like Java or C):
switch (orderSubType) {
case sdcConstants().orderSubType.UNBAR_0:
case sdcConstants().orderSubType.UNBAR_00:
case sdcConstants().orderSubType.UNBAR_OG:
if (item.source == sdcConstants().source.EXT && item.code == sdcConstants().CFSS.CFSS_VOICE_DUNNING) {
item.state = sdcConstants().servAction.DELETE;
break;
}
//FALL THROUGH TO DEFAULT
default:
item.state = sdcConstants().servAction.NO_OPERATION;
break;
}
You can see why I don't think it buys you anything over the if
version in this particular case:
if ( (orderSubType == sdcConstants().orderSubType.UNBAR_0 ||
orderSubType == sdcConstants().orderSubType.UNBAR_00 ||
orderSubType == sdcConstants().orderSubType.UNBAR_OG
)
&& item.source == sdcConstants().source.EXT
&& item.code == sdcConstants().CFSS.CFSS_VOICE_DUNNING
) {
item.state = sdcConstants().servAction.DELETE;
} else {
item.state = sdcConstants().servAction.NO_OPERATION;
}