So, as far as I checked, there is no XOR operator for javascript.
There is tho the following -
if( ( foo && !bar ) || ( !foo && bar ) ) {
...
}
This is clear if foo and bar are boolean values. But can XOR be used to check against a different type of expression? For example if I would like to check a value against another value, that is -
if (type === 'configuration' XOR type2 === 'setup') {
...
}
Would it transform to something like -
if ( (type === 'configuration' && type2 !== 'setup') || (type !== 'configuration' && type2 === 'setup' ) ) {
...
}
Or would it look different?
This gives the following result -
type = 'configuration' && type2 = 'setup': false
type = 'configurations' && type2 = 'setup': true
type = 'configuration' && type2 = 'setups': true
type = 'configurations' && type2 = 'setups': false
Which matches the
0 XOR 0 = 0
0 XOR 1 = 1
1 XOR 0 = 1
1 XOR 1 = 0
but I'm not sure if this will match for all cases.