<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JavaScript Bitwise Operators</title>
</head>
<body>
<pre> <!-- Use pre element for work document.writeln() method -->
<script type="text/javascript">
document.writeln("Bitwise AND :", 5 & 10); // return 0
// calc: 0000 0101 & 0000 1010 = 0000 0000
document.writeln("Bitwise OR :", 5 | 10); // return 15
// calc: 0000 0101 | 0000 1010 = 0000 1111
document.writeln("Bitwise XOR :", 5 ^ 10); // return 15
// calc: 0000 0101 ^ 0000 1010 = 0000 1111
document.writeln("Bitwise NOT :", ~5); // return -6
//calc: ~ 0000 0101 = 1111 1010
document.writeln("Bitwise Shift Left :", 10 << 2); // return 40
// calc: 0000 1010 << 2 = 0010 1000
document.writeln("Bitwise Shift Right :", 10 >> 2); // return 2
// calc: 0000 1010 >> 2 = 0000 0010
document.writeln("Unsigned Shift Right :", 10 >>> 2); // return 2
// calc: 0000 1010 >>> 2 = 0000 0010
</script>
</pre>
</body>
</html>