Friday, September 5, 2025
HomeLanguagesJavascriptBitwise AND Assignment (&=) Operator in JavaScript

Bitwise AND Assignment (&=) Operator in JavaScript

The Bitwise AND Assignment Operator is represented by “&=”. This operator uses the binary representation of both operands and performs the bitwise AND operation and then assigns the result to the left operand. 

This can also be explained as applying the logical AND operation to the first operand and second operand and after that assigning the result to the first operand.

Syntax:

a &= b 
Or
a = a & b

 

Where –

  • a = First operand
  • b = Second operand

Example 1: In this example, we will see the bitwise AND Assignment.

Javascript




let x = 7;      // 00000000000000000000000000000111
x &= 3;         // 00000000000000000000000000000011
  
console.log(x);


Output:

3

Example 2: In this example, we will see the logical AND operation between two operands.

Javascript




let x = 7;
let y = 3;
x &= y;
console.log(x); 
  
x &= 0;
console.log(x);


Output:

3
0

We have a complete list of Javascript Assignment Operators, to go through those please check the Javascript Assignment Operator article.

Supported Browser:

  • Chrome 1
  • Edge 12
  • Firefox 1
  • Opera 3
  • Safari 1
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32265 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11863 POSTS0 COMMENTS
Shaida Kate Naidoo
6752 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6703 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS