Use the Bitwise AND Operator in JavaScript

Description

The following code shows how to use the Bitwise AND Operator.

Example


<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
// integer = 32-bit binary representation
// 11 = 00000000000000000000000000001011
//  6 = 00000000000000000000000000000110
//  2 = 00000000000000000000000000000010
var answer = 11 & 6;<!--from  www .j av  a 2 s  .  c om-->
document.write("11 & 6 = ",answer);
</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Use the Bitwise AND Operator in JavaScript