Favorites

JavaScript & Bitwise AND Operator

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
&
JavaScript Bitwise OperatorThis operator is supported by all modern browsers.
Updated 28th November 2026

The bitwise AND operator (&) compares the bits of two integers and sets each bit to 1 only where both have a 1. It's used for flags and masks.

Description

The bitwise AND operator & converts both operands to 32-bit integers and returns a number whose bits are 1 only where both operands have a 1. It's used to test flags packed into one number, and n & 1 is a quick odd-number check. Don't confuse it with the logical &&.

All bitwise operators work on 32-bit signed integers: decimals are truncated and numbers outside that range wrap around, so they aren't suitable for large values. BigInts are supported if both operands are BigInts, with no size limit.

Bit flags let you store several on/off options in one number, which is compact and fast to test, and appear in some web APIs, such as Node.compareDocumentPosition(). In everyday code, an object of booleans or a Set of option names is usually easier to read.

Properties

Operator
&
Category
Bitwise
Precedence
7 (1 is lowest, 18 is highest)
Associativity
left-to-right

Syntax

x & y

Example

console.log(5 & 3);            // 101 & 011 = 001
const READ = 1, WRITE = 2, EXEC = 4;
const perms = READ | WRITE;
console.log((perms & WRITE) !== 0, (perms & EXEC) !== 0);
console.log(7 & 1 ? 'odd' : 'even');

Browser Support

The following information will show you the current browser support for the & operator. Hover over a browser icon to see the version that first introduced support for this operator.

This operator is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee