Expand Minimize
1 out of 2 rated this helpful - Rate this topic

Bitwise AND Operator (&) (JavaScript)

JavaScript - Internet Explorer 10

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

result = expression1 & expression2
result

The result of the operation.

expression1

Any expression.

expression2

Any expression.

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.

Bit1

Bit2

ANDed Value

0

0

0

1

1

1

1

0

0

0

1

0

The following examples show how to use the & operator.

// 9 is 00000000000000000000000000001001
var expr1 = 9;

// 5 is 00000000000000000000000000000101
var expr2 = 5;

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

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

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards. Also supported in Windows Store apps. See Version Information.

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.