xxxxxxxxxx
let x1 = true || false && false;
let x2 = (true || false) && false;
let x3 = !false && false;
let x4 = !(false && false);
xxxxxxxxxx
const a = 5; // 00000000000000000000000000000101
const b = 3; // 00000000000000000000000000000011
// xor operator ^
console.log(a ^ b); // 00000000000000000000000000000110
// expected output: 6
xxxxxxxxxx
//Javascript xor condition
if ((a && !b) || (!a && b))
{
// code to be exucuted
}
xxxxxxxxxx
// the simplest, cleanest version of the logical XOR operator, that works with any data types, including expressions, is this:
if( !foo != !bar ) {
}
// for values that are only true and false this also works:
if( foo != bar ) {
}