fix some translate error (#34139)
* fix some translate error * Update index.md
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
---
|
||||
title: Let and Const
|
||||
localeTitle: 让和Const
|
||||
localeTitle: let 和 const
|
||||
---
|
||||
## 让
|
||||
## let
|
||||
|
||||
let类似于var但是有范围。 let只能在定义的块级别中访问。
|
||||
let类似于var,但是let有作用域。 let只能在定义的块级作用域中访问。
|
||||
```
|
||||
if (true) {
|
||||
let a = 40;
|
||||
@ -29,9 +29,9 @@ let a = 50;
|
||||
console.log(a); // 50
|
||||
```
|
||||
|
||||
## 常量
|
||||
## const
|
||||
|
||||
Const用于为变量赋值常量。价值无法改变。这是固定的。
|
||||
const声明一个常量。常量的值不能修改。
|
||||
```
|
||||
const a = 50;
|
||||
a = 60; // shows error. You cannot change the value of const.
|
||||
@ -39,7 +39,7 @@ const a = 50;
|
||||
b = "Assigning new value"; // shows error.
|
||||
```
|
||||
|
||||
考虑另一个例子。
|
||||
看另一个例子。
|
||||
```
|
||||
const LANGUAGES = ['Js', 'Ruby', 'Python', 'Go'];
|
||||
LANGUAGES = "Javascript"; // shows error.
|
||||
@ -47,6 +47,6 @@ const LANGUAGES = ['Js', 'Ruby', 'Python', 'Go'];
|
||||
console.log(LANGUAGES); // ['Js', 'Ruby', 'Python', 'Go', 'Java']
|
||||
```
|
||||
|
||||
这可能有点混乱。
|
||||
可能会有点迷惑。
|
||||
|
||||
以这种方式考虑。无论何时定义const变量,Javascript都会将值的地址引用给变量。在我们的示例中,变量'LANGUAGES'实际上引用了分配给数组的内存。因此,您无法在以后更改变量以引用其他内存位置。在整个程序中它只引用数组。
|
||||
换一种方式想。无论何时定义const变量,Javascript都会将值的地址引用给变量。在我们的示例中,变量'LANGUAGES'实际上引用了分配给数组的内存。因此,您无法更改变量以引用其他内存位置。在整个程序中它只引用数组。
|
||||
|
Reference in New Issue
Block a user