Home > Developer > JavaScript
The Javascript bitwiseand assignment operator (&=) Sets the result of a bitwise AND operation on the value of a variable and an expression value. Variables and expressions are treated as 32bit binary values, and the general expressions are all decimal integers, which need to be converted to the corresponding binary, and then 0 forward to complement 32 bits.
& performs a bitwise AND operation on each digit of two 32bit expressions. If the two digits are 1, the result is 1. Otherwise, the result is 0.
bit 1  bit 2  bit and 

0  0  0 
1  1  1 
0  1  0 
1  0  0 
The following example shows how to use the & bitwise AND operator and &= bitwise AND assignment operators:
5 is 00000000000000000000000000000101.
var expr2 = 5;
/*
00000000000000000000000000001001
&
00000000000000000000000000000101
=
00000000000000000000000000000001
=
1
*/
var result = expr1 & expr2;
alert (result);
Popup "1"
Expr1 &= expr2;
alert (EXPR1);
Popup "1"
JavaScript assignment operators and expressions
The JavaScript assignment operator is responsible for assigning values to variables, and the JavaScript assignment operators include =,+=,=,*=,/=,%=
A JavaScript assignment expression that is concatenated with an assignment operator and an Operation object (operand) that conforms to the rule's JavaScript syntax.
JavaScript assignment operators vs. Assignment expression syntax
var i+=a;
+ =Assignment operator
The meaning of the above expression is: The value of I plus a, given the variable i.
JavaScript assignment operators vs. assignment expressions
=
th>
Td>i*=5
operator  = 
+  *= 
/= 
% = 


name  assignment operator  add assignment operator  subtraction assignment operator  multiplication assignment operator  Division assignment operator  modulus assignment operators (remainder assignment operator) 
expression  i=6  i+=5  i=5  i/=5  i%=5  
example  var i=6;  i+=5;  i=5;  i*=5;  i/=5;  i%=5; 
I results  6  one  1  1.2  1  
equivalent to  i=i+5;  i=i5;  i=i*5;  I=I/5;  i=i%5; 