xor in js code example
Example 1: javascript xor
//make an xor condition in javascript
if ((a && !b) || (!a && b)) {
}
Example 2: js Bitwise Operators
Javascript Bitwise Operators
& AND statement
| OR statement
~ NOT
^ XOR
<< Left shift
>> Right shift
>>> Zero fill right shift
Example 3: javascript bitwise flags
var myEnum = {
left: 1,
right: 2,
top: 4,
bottom: 8
}
var myConfig = myEnum.left | myEnum.right;
if (myConfig & myEnum.right) {
// right flag is set
}