Use Bitwise Exclusive OR Operator in JavaScript

Description

The following code shows how to use Bitwise Exclusive OR Operator.

Example


<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
//25 = 0000 0000 0000 0000 0000 0000 0001 1001
// 3 = 0000 0000 0000 0000 0000 0000 0000 0011
//--------------------------------------------
//OR = 0000 0000 0000 0000 0000 0000 0001 1011
<!--from   w w  w  . j ava2  s.com-->
var iResult = 25 | 3;
document.writeln(iResult);    //outputs "27"
</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Use Bitwise Exclusive OR Operator in JavaScript