Skip to content

Commit 14d5641

Browse files
authored
feat: update translation to 2022-07-13 (#1078)
* feat: update translation * feat: update translation * feat: update translation * feat: update translation * feat: update translation * feat: update translation * feat: update translation * feat: update translation * feat: update translation * feat: update translation * feat: update * feat: update translation * feat: update to 2022-07-13
1 parent ce5f0b9 commit 14d5641

File tree

88 files changed

+416
-252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+416
-252
lines changed

1-js/01-getting-started/1-intro/article.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ JavaScript 是将这三件事结合在一起的唯一的浏览器技术。
106106

107107
此类语言的示例有:
108108

109-
- [CoffeeScript](http://coffeescript.org/) 是 JavaScript 的一种语法糖。它引入了更加简短的语法,使我们可以编写更清晰简洁的代码。通常,Ruby 开发者喜欢它。
110-
- [TypeScript](http://www.typescriptlang.org/) 专注于添加“严格的数据类型”以简化开发,以更好地支持复杂系统的开发。由微软开发。
111-
- [Flow](http://flow.org/) 也添加了数据类型,但是以一种不同的方式。由 Facebook 开发。
109+
- [CoffeeScript](https://coffeescript.org/) 是 JavaScript 的一种语法糖。它引入了更加简短的语法,使我们可以编写更清晰简洁的代码。通常,Ruby 开发者喜欢它。
110+
- [TypeScript](https://www.typescriptlang.org/) 专注于添加“严格的数据类型”以简化开发,以更好地支持复杂系统的开发。由微软开发。
111+
- [Flow](https://flow.org/) 也添加了数据类型,但是以一种不同的方式。由 Facebook 开发。
112112
- [Dart](https://www.dartlang.org/) 是一门独立的语言。它拥有自己的引擎,该引擎可以在非浏览器环境中运行(例如手机应用),它也可以被编译成 JavaScript。由 Google 开发。
113113
- [Brython](https://brython.info/) 是一个 Python 到 JavaScript 的转译器,让我们可以在不使用 JavaScript 的情况下,以纯 Python 编写应用程序。
114114
- [Kotlin](https://kotlinlang.org/docs/reference/js-overview.html) 是一个现代、简洁且安全的编程语言,编写出的应用程序可以在浏览器和 Node 环境中运行。

1-js/01-getting-started/2-manuals-specifications/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ JavaScript 是一门还在发展中的语言,定期会添加一些新的功能
2929

3030
要查看它们在基于浏览器的引擎及其他引擎中的支持情况,请看:
3131

32-
- <http://caniuse.com> —— 每个功能的支持表,例如,查看哪个引擎支持现代加密(cryptography)函数:<http://caniuse.com/#feat=cryptography>
32+
- <https://caniuse.com> —— 每个功能的支持表,例如,查看哪个引擎支持现代加密(cryptography)函数:<https://caniuse.com/#feat=cryptography>
3333
- <https://kangax.github.io/compat-table> —— 一份列有语言功能以及引擎是否支持这些功能的表格。
3434

3535
所有这些资源在实际开发中都有用武之地,因为它们包含了有关语言细节,以及它们被支持的程度等非常有价值的信息。

1-js/01-getting-started/3-code-editors/article.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ IDE 加载项目(通常包含很多文件),并且允许在不同文件之
1313
如果你还没考虑好选哪一款 IDE,可以考虑下面两个:
1414

1515
- [Visual Studio Code](https://code.visualstudio.com/)(跨平台,免费)。
16-
- [WebStorm](http://www.jetbrains.com/webstorm/)(跨平台,收费)。
16+
- [WebStorm](https://www.jetbrains.com/webstorm/)(跨平台,收费)。
1717

1818
对于 Windows 系统来说,也有个叫 "Visual Studio" 的 IDE,请不要跟 "Visual Studio Code" 混淆。"Visual Studio" 是一个收费的、强大的 Windows 专用编辑器,它十分适合于 .NET 开发。用它进行 JavaScript 开发也不错。"Visual Studio" 有个免费的版本 [Visual Studio Community](https://www.visualstudio.com/vs/community/)
1919

@@ -31,7 +31,6 @@ IDE 加载项目(通常包含很多文件),并且允许在不同文件之
3131

3232
下面是一些值得你关注的“轻量编辑器”:
3333

34-
- [Atom](https://atom.io/)(跨平台,免费)。
3534
- [Sublime Text](http://www.sublimetext.com)(跨平台,共享软件)。
3635
- [Notepad++](https://notepad-plus-plus.org/)(Windows,免费)。
3736
- [Vim](http://www.vim.org/)[Emacs](https://www.gnu.org/software/emacs/) 也很棒,如果你知道怎么使用它们的话。

1-js/02-first-steps/04-variables/article.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ let message = 'Hello';
6464
```
6565

6666
一些程序员采用下面的形式书写多个变量:
67+
6768
```js no-beautify
6869
let user = 'John',
6970
age = 25,
@@ -103,6 +104,7 @@ let user = 'John'
103104
我们可以在盒子内放入任何值。
104105
105106
并且,这个盒子的值,我们想改变多少次,就可以改变多少次:
107+
106108
```js run
107109
let message;
108110
@@ -192,7 +194,7 @@ let my-name; // 连字符 '-' 不允许用于变量命名
192194
```
193195

194196
```smart header="区分大小写"
195-
命名为 `apple` 和 `AppLE` 的变量是不同的两个变量。
197+
命名为 `apple` 和 `APPLE` 的变量是不同的两个变量。
196198
```
197199

198200
````smart header="允许非英文字母,但不推荐"
@@ -260,7 +262,6 @@ myBirthday = '01.01.2001'; // 错误,不能对常量重新赋值
260262
261263
当程序员能确定这个变量永远不会改变的时候,就可以使用 `const` 来确保这种行为,并且清楚地向别人传递这一事实。
262264
263-
264265
### 大写形式的常数
265266
266267
一个普遍的做法是将常量用作别名,以便记住那些在执行之前就已知的难以记住的值。
@@ -291,6 +292,7 @@ alert(color); // #FF7F00
291292
作为一个“常数”,意味着值永远不变。但是有些常量在执行之前就已知了(比如红色的十六进制值),还有些在执行期间被“计算”出来,但初始赋值之后就不会改变。
292293
293294
例如:
295+
294296
```js
295297
const pageLoadTime = /* 网页加载所需的时间 */;
296298
```

1-js/02-first-steps/05-types/article.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,20 @@ n = 12.345;
6868

6969
## BigInt 类型 [#bigint-type]
7070

71-
在 JavaScript 中,"number" 类型无法表示大于 <code>(2<sup>53</sup>-1)</code>(即 `9007199254740991`),或小于 <code>-(2<sup>53</sup>-1)</code> 的整数。这是其内部表示形式导致的技术限制
71+
在 JavaScript 中,"number" 类型无法安全地表示大于 <code>(2<sup>53</sup>-1)</code>(即 `9007199254740991`),或小于 <code>-(2<sup>53</sup>-1)</code> 的整数。
7272

73-
在大多数情况下,这个范围就足够了,但有时我们需要很大的数字,例如用于加密或微秒精度的时间戳。
73+
更准确的说,"number" 类型可以存储更大的整数(最多 <code>1.7976931348623157 * 10<sup>308</sup></code>),但超出安全整数范围 <code>±(2<sup>53</sup>-1)</code> 会出现精度问题,因为并非所有数字都适合固定的 64 位存储。因此,可能存储的是“近似值”。
74+
75+
例如,这两个数字(正好超出了安全整数范围)是相同的:
76+
77+
```js
78+
console.log(9007199254740991 + 1); // 9007199254740992
79+
console.log(9007199254740991 + 2); // 9007199254740992
80+
```
81+
82+
也就是说,所有大于 <code>(2<sup>53</sup>-1)</code> 的奇数都不能用 "number" 类型存储。
83+
84+
在大多数情况下,<code>±(2<sup>53</sup>-1)</code> 范围就足够了,但有时候我们需要整个范围非常大的整数,例如用于密码学或微秒精度的时间戳。
7485

7586
`BigInt` 类型是最近被添加到 JavaScript 语言中的,用于表示任意长度的整数。
7687

@@ -261,16 +272,18 @@ typeof alert // "function" (3)
261272
262273
## 总结
263274
264-
JavaScript 中有八种基本的数据类型(译注:前七种为基本数据类型,也称为原始类型,而 `object` 为复杂数据类型)。
265-
266-
- `number` 用于任何类型的数字:整数或浮点数,在 <code>±(2<sup>53</sup>-1)</code> 范围内的整数。
267-
- `bigint` 用于任意长度的整数。
268-
- `string` 用于字符串:一个字符串可以包含 0 个或多个字符,所以没有单独的单字符类型。
269-
- `boolean` 用于 `true``false`
270-
- `null` 用于未知的值 —— 只有一个 `null` 值的独立类型。
271-
- `undefined` 用于未定义的值 —— 只有一个 `undefined` 值的独立类型。
272-
- `symbol` 用于唯一的标识符。
273-
- `object` 用于更复杂的数据结构。
275+
JavaScript 中有八种基本的数据类型(译注:前七种为基本数据类型,也称为原始数据类型,而 `object` 为复杂数据类型)。
276+
277+
- 七种原始数据类型:
278+
- `number` 用于任何类型的数字:整数或浮点数,在 <code>±(2<sup>53</sup>-1)</code> 范围内的整数。
279+
- `bigint` 用于任意长度的整数。
280+
- `string` 用于字符串:一个字符串可以包含 0 个或多个字符,所以没有单独的单字符类型。
281+
- `boolean` 用于 `true``false`
282+
- `null` 用于未知的值 —— 只有一个 `null` 值的独立类型。
283+
- `undefined` 用于未定义的值 —— 只有一个 `undefined` 值的独立类型。
284+
- `symbol` 用于唯一的标识符。
285+
- 以及一种非原始数据类型:
286+
- `object` 用于更复杂的数据结构。
274287
275288
我们可以通过 `typeof` 运算符查看存储在变量中的数据类型。
276289
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
答案:`null`,因为它是列表中第一个假值。
22

33
```js run
4-
alert( 1 && null && 2 );
4+
alert(1 && null && 2);
55
```
66

1-js/02-first-steps/13-while-for/article.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66

77
**循环** 是一种重复运行同一代码的方法。
88

9+
```smart header="for..of 和 for..in 循环"
10+
给进阶读者的一个小提示。
11+
12+
本文仅涵盖了基础的循环:`while`,`do..while` 和 `for(..; ..; ..)`。
13+
14+
如果你阅读本文是为了寻找其他类型的循环,那么:
15+
16+
- 用于遍历对象属性的 `for..in` 循环请见:[for..in](info:object#forin)。
17+
- 用于遍历数组和可迭代对象的循环分别请见:[for..of](info:array#loops) 和 [iterables](info:iterable)。
18+
19+
否则,请继续阅读。
20+
```
21+
922
## "while" 循环
1023

1124
`while` 循环的语法如下:
@@ -162,10 +175,8 @@ for (i = 0; i < 3; i++) { // 使用现有的变量
162175
163176
alert(i); //3,可见,因为是在循环之外声明的
164177
```
165-
166178
````
167179

168-
169180
### 省略语句段
170181

171182
`for` 循环的任何语句段都可以被省略。
@@ -286,7 +297,6 @@ if (i > 5) {
286297
287298
……用问号重写:
288299
289-
290300
```js no-beautify
291301
(i > 5) ? alert(i) : *!*continue*/!*; // continue 不允许在这个位置
292302
```
@@ -321,6 +331,7 @@ alert('Done!');
321331
`input` 之后的普通 `break` 只会打破内部循环。这还不够 —— 标签可以实现这一功能!
322332

323333
**标签** 是在循环之前带有冒号的标识符:
334+
324335
```js
325336
labelName: for (...) {
326337
...
@@ -342,6 +353,7 @@ labelName: for (...) {
342353
// 用得到的值做些事……
343354
}
344355
}
356+
345357
alert('Done!');
346358
```
347359

@@ -362,13 +374,15 @@ for (let i = 0; i < 3; i++) { ... }
362374
标签不允许我们跳到代码的任意位置。
363375
364376
例如,这样做是不可能的:
377+
365378
```js
366379
break label; // 跳转至下面的 label 处(无效)
367380
368381
label: for (...)
369382
```
370383
371384
`break` 指令必须在代码块内。从技术上讲,任何被标记的代码块都有效,例如:
385+
372386
```js
373387
label: {
374388
// ...

1-js/02-first-steps/16-function-expressions/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ ask("Do you agree?", showOk, showCancel);
150150

151151
主要思想是我们传递一个函数,并期望在稍后必要时将其“回调”。在我们的例子中,`showOk` 是回答 "yes" 的回调,`showCancel` 是回答 "no" 的回调。
152152

153-
我们可以用函数表达式对同样的函数进行大幅简写
153+
我们可以使用函数表达式来编写一个等价的、更简洁的函数
154154

155155
```js run no-beautify
156156
function ask(question, yes, no) {
@@ -186,7 +186,7 @@ ask(
186186

187187
首先是语法:如何通过代码对它们进行区分。
188188

189-
- **函数声明**:在主代码流中声明为单独的语句的函数
189+
- **函数声明**:在主代码流中声明为单独的语句的函数
190190

191191
```js
192192
// 函数声明

1-js/02-first-steps/18-javascript-specials/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ for(;;) {
5555

5656
该指令必须位于 JavaScript 脚本的顶部或函数体的开头。
5757

58-
如果没有 `"use strict"`,所有东西仍可以正常工作,但是某些特性的表现方式与旧式「兼容」方式相同。我们通常更喜欢现代的方式。
58+
如果没有 `"use strict"`,所有东西仍可以正常工作,但某些功能将以老式的“兼容”方式运行。我们通常更喜欢现代的方式。
5959

6060
语言的一些现代特征(比如我们将来要学习的类)会隐式地启用严格模式。
6161

@@ -144,7 +144,7 @@ JavaScript 支持以下运算符:
144144
: 简单的赋值:`a = b` 和合并了其他操作的赋值:`a * = 2`
145145

146146
按位运算符
147-
: 按位运算符在最低位级上操作 32 位的整数:详见 [文档](mdn:/JavaScript/Guide/Expressions_and_Operators#Bitwise)
147+
: 按位运算符在最低位级上操作 32 位的整数:详见 [文档](mdn:/JavaScript/Guide/Expressions_and_Operators#bitwise_operators)
148148

149149
三元运算符
150150
: 唯一具有三个参数的操作:`cond ? resultA : resultB`。如果 `cond` 为真,则返回 `resultA`,否则返回 `resultB`

1-js/03-code-quality/01-debugging-chrome/chrome-open-sources.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)