From 01b0e12ba27b5069248fd09235e9a7143915ee30 Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:02:49 +0800 Subject: remove `notranslate` class in zh-CN --- .../zh-cn/web/javascript/reference/statements/const/index.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/statements/const') diff --git a/files/zh-cn/web/javascript/reference/statements/const/index.html b/files/zh-cn/web/javascript/reference/statements/const/index.html index b096efd17f..de8e0c7f39 100644 --- a/files/zh-cn/web/javascript/reference/statements/const/index.html +++ b/files/zh-cn/web/javascript/reference/statements/const/index.html @@ -19,7 +19,7 @@ translation_of: Web/JavaScript/Reference/Statements/const

语法

-
const name1 = value1 [, name2 = value2 [, ... [, nameN = valueN]]];
+
const name1 = value1 [, name2 = value2 [, ... [, nameN = valueN]]];
nameN
@@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Statements/const

常量在声明的时候可以使用大小写,但通常情况下全部用大写字母。

-
// 定义常量MY_FAV并赋值7
+
// 定义常量MY_FAV并赋值7
 const MY_FAV = 7;
 
 // 报错 - Uncaught TypeError: Assignment to constant variable.
@@ -69,7 +69,7 @@ let MY_FAV = 20;
 
 

注意块作用域的性质很重要

-
if (MY_FAV === 7) {
+
if (MY_FAV === 7) {
   // 没问题,并且创建了一个块作用域变量 MY_FAV
   // (works equally well with let to declare a block scoped non const variable)
   let MY_FAV = 20;
@@ -87,7 +87,7 @@ console.log('my favorite number is ' + MY_FAV);
 
 

常量要求一个初始值

-
// 报错
+
// 报错
 // Uncaught SyntaxError: Missing initializer in const declaration
 
 const FOO;
@@ -97,7 +97,7 @@ const FOO;
 
 

常量可以定义成对象和数组

-
const MY_OBJECT = {'key': 'value'};
+
const MY_OBJECT = {'key': 'value'};
 
 // 重写对象和上面一样会失败
 // Uncaught TypeError: Assignment to constant variable.
-- 
cgit v1.2.3-54-g00ecf