Javascript Reference
Categories: Operators

javascript Operators &

@March 15, 2008, 1:22 a.m.
& Firefox/Netscape/NN 2 IE 3 ECMA 1  

  

The bitwise AND operator performs binary math on two operands (their binary values). Each column of bits is subjected to the Boolean AND operation. If the value of a column in both operands is 1, the result for that column position is 1. All other combinations yield a zero. The resulting value of the operator is the decimal equivalent of the binary result. For example, the binary values of 3 and 6 are 0011 and 0110, respectively. After an AND operation on these two values, the binary result is 0010; the decimal equivalent is 2.

 
Example
 
var n = 3 & 6;

Powered by Linode.