From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../reference/operators/assignment/index.html | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/operators/assignment/index.html (limited to 'files/zh-cn/web/javascript/reference/operators/assignment') diff --git a/files/zh-cn/web/javascript/reference/operators/assignment/index.html b/files/zh-cn/web/javascript/reference/operators/assignment/index.html new file mode 100644 index 0000000000..eba07d8890 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/operators/assignment/index.html @@ -0,0 +1,62 @@ +--- +title: 赋值运算符(=) +slug: Web/JavaScript/Reference/Operators/Assignment +tags: + - JavaScript + - 参考 + - 操作者 + - 语言特性 + - 赋值运算符 +translation_of: Web/JavaScript/Reference/Operators/Assignment +--- +
{{jsSidebar("Operators")}}
+ +

简单赋值操作符(=)用于为变量赋值。赋值表达式本身的值为其完成后被赋值的变量的值。为了给多个变量赋一个值,可以链式使用赋值操作符。

+ +
{{EmbedInteractiveExample("pages/js/expressions-assignment.html")}}
+ +
+ + + +

语法

+ +
Operator: x = y
+
+ +

示例

+ +

简单赋值和链式赋值

+ +
// 假设已经存在以下变量
+//  x = 5
+//  y = 10
+//  z = 25
+
+x = y     // x 为 10
+x = y = z // x, y 都为 25
+ +

规范

+ + + + + + + + + + +
Specification
{{SpecName('ESDraft', '#sec-assignment-operators', 'Assignment operators')}}
+ +

浏览器支持

+ + + +

{{Compat("javascript.operators.assignment")}}

+ +

相关链接

+ + -- cgit v1.2.3-54-g00ecf