aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/operators/bitwise_and_assignment/index.html
blob: 90e4085f438728d2f749f6f14433fa7b3b05ef0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---
title: 按位与赋值(&=)
slug: Web/JavaScript/Reference/Operators/Bitwise_AND_assignment
tags:
  - JavaScript
  - 按位与赋值运算
  - 操作符运算
translation_of: Web/JavaScript/Reference/Operators/Bitwise_AND_assignment
---
<div>{{jsSidebar("Operators")}}</div>

<div>按位与赋值运算符(&=)表示两个操作数的二进制,对它们进行按位AND运算并将结果分配给变量。</div>

<div>{{EmbedInteractiveExample("pages/js/expressions-bitwise-and-assignment.html")}}</div>





<h2 id="语法">语法</h2>

<pre class="syntaxbox"><strong>Operator:</strong> x &amp;= y
<strong>Meaning:</strong>  x  = x &amp; y
</pre>

<h2 id="例子">例子</h2>

<h3 id="按位与赋值运算">按位与赋值运算</h3>

<pre class="brush: js">let a = 5;
// 5:     00000000000000000000000000000101
// 2:     00000000000000000000000000000010
a &amp;= 2; // 0</pre>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-assignment-operators', 'Assignment operators')}}</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>



<p>{{Compat("javascript.operators.bitwise_and_assignment")}}</p>

<h2 id="参见">参见</h2>

<ul>
 <li><a href="/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Assignment">Assignment operators in the JS guide</a></li>
 <li><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_AND">Bitwise AND operator</a></li>
</ul>