This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

bitwise and

Summary

Performs a bitwise AND operation on two 32-bit expressions.

Syntax

result = expression1 & expression2
result
The result of the operation.
expression1
Any expression.
expression2
Any expression.

Examples

The following examples show how to use the & operator. See Remarks for more information.

// 9 is 00000000000000000000000000001001
var expr1 = 9;

// 5 is 00000000000000000000000000000101
var expr2 = 5;

// 1 is 00000000000000000000000000000001
var result = expr1 & expr2;

document.write(result);
// Output: 1

Remarks

The & does a bitwise AND operation on the each of the bits of two 32-bit expressions. If both of the bits are 1, the result is 1. Otherwise, the result is 0.

Bit1Bit2ANDed Value
000
111
100
010

See also

Other articles

Attributions

  • Microsoft Developer Network: Article