Skip to content

Fix some typo and improve translation #348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 1-js/01-getting-started/1-intro/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ JavaScript 的能力依赖于它执行的环境。例如:[Node.js](https://wik
- 在网页中插入新的 HTML,修改现有的网页内容和网页的样式。
- 响应用户的行为,响应鼠标的点击或移动、键盘的敲击。
- 向远程服务器发送请求,使用 [AJAX](https://en.wikipedia.org/wiki/Ajax_(programming)) 和 [COMET](https://en.wikipedia.org/wiki/Comet_(programming)) 技术下载或上传文件。
- 获取或修改 cookie,向用访问者提出问题、发送消息。
- 获取或修改 cookie,向访问者提出问题、发送消息。
- 记住客户端的数据(本地存储)。

## 浏览器中的 JavaScript 不能做什么?
Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/16-javascript-specials/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ for(;;) {
- 非拉丁字母和象形文字也是允许的,但通常不会使用。


变量的值可以动态改变数据类型,它们可以存储任何价
变量的值可以动态改变数据类型,它们可以存储任何值

```js
let x = 5;
Expand Down
2 changes: 1 addition & 1 deletion 1-js/03-code-quality/02-coding-style/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ function pow(x, n) {
最出名的工具有:

- [JSLint](http://www.jslint.com/) -- 第一批 linters 之一。
- [JSHint](http://www.jshint.com/) -- 比 JSHint 多了更多设置。
- [JSHint](http://www.jshint.com/) -- 比 JSLint 多了更多设置。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个没错吧?你看下链接

Copy link
Collaborator Author

@lycheeEng lycheeEng Jun 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

英文版 Coding StyleJSHint – more settings than JSLint.
翻译的原文是 JSHintJSHint 多了更多的设置,而应该是比 JSLint,所以这里的原先翻译还是有点点问题

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

注意到了,你是对的,感谢 PR.

- [ESLint](http://eslint.org/) -- 可能是最新的一个。

它们都能够做这些工作。笔者使用 [ESLint](http://eslint.org/).
Expand Down
2 changes: 1 addition & 1 deletion 1-js/03-code-quality/03-comments/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ complex;
code;
```

但在良好的代码中,这种“解释性”评论的数量应该是最小的。严肃的说,就算没有它们,代码也应该很容易理解。
但在良好的代码中,这种“解释性”注释的数量应该是最小的。严肃的说,就算没有它们,代码也应该很容易理解。

关于这一点有一个很棒的原则:“如果代码不够清晰以至于需要一个注释,那么或许它应该被重写。”

Expand Down
2 changes: 1 addition & 1 deletion 1-js/04-object-basics/01-object/article.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# 对象

正如我们从《引言:类型》那章中知道的那样,JavaScript 中有很七种类型。有六种原始类型,因为他们的值只包含一种东西(字符串,数值或者其他)。
正如我们从《引言:类型》那章中知道的那样,JavaScript 中有七种数据类型。有六种原始类型,因为他们的值只包含一种东西(字符串,数值或者其他)。
相反,对象用来存储键值对和更复杂的实体。在 JavaScript 中,对象深入到这门语言的方方面面。所以在我们深入理解这门语言之前,必须先理解对象。

对象可以通过花括号 `{…}` 和其中包含一些可选的**属性**来创建。属性是一个键值对,键是一个字符串(也叫做属性名),值可以是任何类型。
Expand Down
2 changes: 1 addition & 1 deletion 1-js/04-object-basics/05-object-toprimitive/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

在对象中有特殊的方法用来做转换。

在 <info:type-conversions> 一章中,我们已经看到了数值,字符串和布尔转换的规则。但是我们给对象留了一个空隙。正如我们所知道的方法和符号一样,现在我们可以关闭它
在 <info:type-conversions> 一章中,我们已经看到了数值,字符串和布尔转换的规则。但是我们给对象的原始值转换留下了一点疑问。正如我们所知道的方法和符号一样,现在我们可以解决这个问题了

对于对象,不存在 to-boolean 转换,因为所有对象在布尔上下文中都是 `true`。所以只有字符串和数值转换。

Expand Down
2 changes: 1 addition & 1 deletion 1-js/05-data-types/02-number/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ alert( 0.1 + 0.2 ); // 0.30000000000000004

一个数字以二进制形式存储在内存中,一个 1 和 0 的序列。但是像十进制数字系统看起来很简单的 `0.1`,`0.2` 这样的分数实际上是二进制形式的无限分数。

换句话说,什么是 `0.1`?十分之一除以十分之一,即十分之一。在十进制数字系统中,这些数字很容易表示。将它比作三分之一:`1/3`。它变成了无尽的分数 `0.33333(3)`。
换句话说,什么是 `0.1`?`0.1` 就是把 1 除以 10 `1/10`,即十分之一。在十进制数字系统中,这些数字很容易表示。将它比作三分之一:`1/3`。它变成了无尽的分数 `0.33333(3)`。

所以,按这种用 `10` 划分可以保证在十进制系统中运行良好,但用 `3` 划分不是。出于同样的原因,在二进制数字系统中,`2` 的幂的分割保证工作,但 `1/10` 变成一个无限的二进制分数。

Expand Down
2 changes: 1 addition & 1 deletion 1-js/05-data-types/03-string/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ alert( str );

### 正确的比较

执行字符串比较的“正确”算法比看起来更复杂,因为不同语言的字母都不想同。相同的字母可能位于不同的字母表中。
执行字符串比较的“正确”算法比看起来更复杂,因为不同语言的字母都不相同。相同的字母可能位于不同的字母表中。

因此浏览器需要知道要比较的语言。

Expand Down
2 changes: 1 addition & 1 deletion 1-js/05-data-types/04-array/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ alert( arr === fruits ); // true

arr.push("Pear"); // 通过引用修改数组

alert( fruits ); // Banana, Pear — 现在只有 2 项了
alert( fruits ); // Banana, Pear — 现在有 2 项了
```

...但是数组真正特殊的是它们的内部实现。JavaScript 引擎尝试把这些元素一个接一个地存储在连续的内存区域,就像本章的插图显示的一样,而且还有一些其它的优化,以使数组运行得非常快。
Expand Down
2 changes: 1 addition & 1 deletion 1-js/05-data-types/05-array-methods/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ let users = [
];

*!*
// 找到比 users 小的所有 user
// 找到比 user 小的所有 users
let youngerUsers = users.filter(user.younger, user);
*/!*

Expand Down
4 changes: 2 additions & 2 deletions 1-js/05-data-types/07-map-set-weakmap-weakset/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ map.set('1', 'str1'); // 字符串作为 key
map.set(1, 'num1'); // 数字作为 key
map.set(true, 'bool1'); // 布尔值作为 key

// 还记得普通对象 Object 吗?它将会吧所有的键转化为字符串类型
// 还记得普通对象 Object 吗?它将会把所有的键转化为字符串类型
// 但是 Map 将会保留键的类型,所以下面这两个是不同的:
alert( map.get(1) ); // 'num1'
alert( map.get('1') ); // 'str1'
Expand Down Expand Up @@ -395,7 +395,7 @@ let unreadSet = new WeakSet(messages);

// 我们可以使用 unreadSet 来看一个 message 是否未读
alert(unreadSet.has(messages[1])); // true
// 读过之后就讲它从 set 中移除
// 读过之后就将它从 set 中移除
unreadSet.delete(messages[1]); // true

// 当我们对消息列表做 shift 操作,set 就会自动清理
Expand Down
2 changes: 1 addition & 1 deletion 1-js/05-data-types/08-keys-values-entries/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

单个数据结构告一段落,下面我们让讨论如何迭代它们。

在前面的章节中,我们认识了 `map.keys()`,`map.value()`,`map.entries()`。
在前面的章节中,我们认识了 `map.keys()`,`map.values()`,`map.entries()`。

这些方法是通用的,有一个共同的约定来将它们用于各种数据结构。如果我们创建一个我们自己的数据结构,我们也应该实现这些方法。

Expand Down
2 changes: 1 addition & 1 deletion 1-js/06-advanced-functions/01-recursion/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ let arr = [obj1, obj2, obj3];

...但是用数组有个问题。「删除元素」和「插入元素」操作代价非常大。例如,`arr.unshift(obj)` 操作必须对所有元素重新编号以便为新的元素 `obj` 腾出空间,而且如果数组很大,会很耗时。`arr.shift()` 同理。

唯一对数组结构做修改而不需要大量重排的操作就是在数组的两端:`arr.push/pop`。所以对大队列来说,数组会很慢。
唯一对数组结构做修改而不需要大量重排的操作就是在数组的末端:`arr.push/pop`。所以对大队列来说,数组会很慢。

如果我们真的需要快速插入、删除的话,我们可以选择另一种叫做[链表](https://en.wikipedia.org/wiki/Linked_list)的数据结构。

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion 2-ui/1-document/02-dom-nodes/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ drawHtmlTree(node6, 'div.domtree', 690, 500);

表示整个文档的 `document` 对象在形式上也是一个 DOM 节点。

有 [12 中节点类型](https://dom.spec.whatwg.org/#node)。实际上,我们通常用到的是其中的 4 个:
有 [12 种节点类型](https://dom.spec.whatwg.org/#node)。实际上,我们通常用到的是其中的 4 个:

1. `document`—— DOM 中的“入口点”。
2. 元素节点 —— HTML 标签,树构建块。
Expand Down
2 changes: 1 addition & 1 deletion 2-ui/1-document/04-searching-elements-dom/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ CSS 选择器的伪类,如 `:hover` 和 `:active` 都是被支持的。例如
</tbody>
</table>

请注意,只有在文档 `document.getElementById(...)` 的上下文中才能调用 `getElementById` 和 `getElementsByName`。但元素中没有 `elem.getElementById(...)` 回报错
请注意,只有在文档 `document.getElementById(...)` 的上下文中才能调用 `getElementById` 和 `getElementsByName`。但元素中没有 `elem.getElementById(...)` 会报错

也可以在元素上调用其他方法,例如 `elem.querySelectorAll(...)` 将会在 `elem`(在 DOM 子树中)内部进行搜素。

Expand Down
2 changes: 1 addition & 1 deletion 2-ui/1-document/07-modifying-document/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DOM(document object model 文档对象模型,此文中全部以缩写 DOM

以下的例子向我们展示如何创建一个“弹幕”新元素并且修改它在页面中展示的内容。

这里我们先展示出一个建单的例子,随后会逐一向你说明。
这里我们先展示出一个简单的例子,随后会逐一向你说明。

## 例子:展示一条信息

Expand Down
2 changes: 1 addition & 1 deletion 2-ui/1-document/09-size-and-scroll/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ JavaScript 中存在许多属性让我们能够读取元素的宽度、高度或

1. CSS 定位(`position` 为 `absolute`、`relative` 或 `fixed`),
2. 或者 `<td>`、`<th>`、`<table>`,
2. 或者 `<body>`。
3. 或者 `<body>`。

在大多数实际情况下,我们可以使用 `offsetParent` 来获得最近的 CSS 定位祖先。`offsetLeft/offsetTop` 提供相对于元素左上角的 x/y 坐标。

Expand Down