xor in javascript
//make an xor condition in javascript
if ((a && !b) || (!a && b)) {
}
4.33
3
var myEnum = {
left: 1,
right: 2,
top: 4,
bottom: 8
}
var myConfig = myEnum.left | myEnum.right;
if (myConfig & myEnum.right) {
// right flag is set
}
Thank you!
3
0
4.25
8
x ^ y
Thank you!
8
0
3.67
6
const a = 5; // 00000000000000000000000000000101
const b = 3; // 00000000000000000000000000000011
// xor operator ^
console.log(a ^ b); // 00000000000000000000000000000110
// expected output: 6
Thank you!
6
0
0
6
if (a != b)
Thank you!
6
0
Are there any code examples left?
New code examples in category Javascript