Skip to content

Commit a7a4cfb

Browse files
authored
Update from upstream to 2020-07-18 (#799)
1 parent 6f21f12 commit a7a4cfb

File tree

11 files changed

+13
-13
lines changed

11 files changed

+13
-13
lines changed

1-js/02-first-steps/10-ifelse/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 条件运算符:if 和 '?'
1+
# 条件分支:if 和 '?'
22

33
有时我们需要根据不同条件执行不同的操作。
44

1-js/02-first-steps/12-nullish-coalescing-operator/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ alert(height ?? 100); // 0
6868
6969
## 优先级
7070
71-
`??` 运算符的优先级相当低:在 [MDN table](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table) 中为 `7`
71+
`??` 运算符的优先级相当低:在 [MDN table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table) 中为 `5`
7272
7373
因此,`??` 在大多数其他运算之后,但在 `=``?` 之前进行运算。
7474

1-js/03-code-quality/02-coding-style/1-style-errors/solution.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function pow(x,n) // <- 参数之间没有空格
1212

1313
let x=prompt("x?",''), n=prompt("n?",'') // <-- 从技术的角度来看是可以的,
1414
// 但是拆分成 2 行会更好,并且这里也缺了空格和分号 ;
15-
if (n<0) // <- (n < 0) 里面没有空格,并且应该在本行上面加一个空行
15+
if (n<=0) // <- (n <= 0) 里面没有空格,并且应该在本行上面加一个空行
1616
{ // <- 花括号独占了一行
1717
// 下面的一行代码太长了,可以将其拆分成 2 行以提高可读性
1818
alert(`Power ${n} is not supported, please enter an integer number greater than zero`);
@@ -39,7 +39,7 @@ function pow(x, n) {
3939
let x = prompt("x?", "");
4040
let n = prompt("n?", "");
4141

42-
if (n < 0) {
42+
if (n <= 0) {
4343
alert(`Power ${n} is not supported,
4444
please enter an integer number greater than zero`);
4545
} else {

1-js/04-object-basics/03-garbage-collection/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ JavaScript 中主要的内存管理概念是 **可达性**。
2323

2424
2. 如果一个值可以通过引用或引用链从根访问任何其他值,则认为该值是可达的。
2525

26-
比方说,如果局部变量中有一个对象,并且该对象有一个属性引用了另一个对象,则该对象被认为是可达的。而且它引用的内容也是可达的。下面是详细的例子。
26+
比方说,如果全局变量中有一个对象,并且该对象有一个属性引用了另一个对象,则该对象被认为是可达的。而且它引用的内容也是可达的。下面是详细的例子。
2727

2828
在 JavaScript 引擎中有一个被称作 [垃圾回收器](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) 的东西在后台执行。它监控着所有对象的状态,并删除掉那些已经不可达的。
2929

1-js/04-object-basics/08-symbol/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ let id = Symbol("id");
133133
let user = {
134134
name: "John",
135135
*!*
136-
[id]: 123 // 而不是 "id:123"
136+
[id]: 123 // 而不是 "id":123
137137
*/!*
138138
};
139139
```

1-js/08-prototypes/04-prototype-methods/article.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
现代的方法有:
99

10-
- [Object.create(proto[, descriptors])](mdn:js/Object/create) —— 利用给定的 `proto` 作为 `[[Prototype]]` 和可选的属性描述来创建一个空对象。
10+
- [Object.create(proto, [descriptors])](mdn:js/Object/create) —— 利用给定的 `proto` 作为 `[[Prototype]]` 和可选的属性描述来创建一个空对象。
1111
- [Object.getPrototypeOf(obj)](mdn:js/Object/getPrototypeOf) —— 返回对象 `obj``[[Prototype]]`
1212
- [Object.setPrototypeOf(obj, proto)](mdn:js/Object/setPrototypeOf) —— 将对象 `obj``[[Prototype]]` 设置为 `proto`
1313

@@ -175,7 +175,7 @@ alert(Object.keys(chineseDictionary)); // hello,bye
175175

176176
设置和直接访问原型的现代方法有:
177177

178-
- [Object.create(proto[, descriptors])](mdn:js/Object/create) —— 利用给定的 `proto` 作为 `[[Prototype]]`(可以是 `null`)和可选的属性描述来创建一个空对象。
178+
- [Object.create(proto, [descriptors])](mdn:js/Object/create) —— 利用给定的 `proto` 作为 `[[Prototype]]`(可以是 `null`)和可选的属性描述来创建一个空对象。
179179
- [Object.getPrototypeOf(obj)](mdn:js/Object/getPrototypeOf) —— 返回对象 `obj``[[Prototype]]`(与 `__proto__` 的 getter 相同)。
180180
- [Object.setPrototypeOf(obj, proto)](mdn:js/Object/setPrototypeOf) —— 将对象 `obj``[[Prototype]]` 设置为 `proto`(与 `__proto__` 的 setter 相同)。
181181

1-js/09-classes/06-instanceof/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ alert( {}.toString.call(user) ); // [object User]
190190

191191
```js run
192192
// 特定于环境的对象和类的 toStringTag:
193-
alert( window[Symbol.toStringTag]); // window
193+
alert( window[Symbol.toStringTag]); // Window
194194
alert( XMLHttpRequest.prototype[Symbol.toStringTag] ); // XMLHttpRequest
195195

196196
alert( {}.toString.call(window) ); // [object Window]

1-js/11-async/04-promise-error-handling/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ new Promise((resolve, reject) => {
122122
在下面的例子中,我们可以看到 `.catch` 的另一种情况。`(*)` 行的处理程序(handler)捕获了 error,但无法处理它(例如,它只知道如何处理 `URIError`),所以它将其再次抛出:
123123

124124
```js run
125-
// 执行流:catch -> catch -> then
125+
// 执行流:catch -> catch
126126
new Promise((resolve, reject) => {
127127

128128
throw new Error("Whoops!");

2-ui/3-event-details/4-mouse-drag-and-drop/ball.view/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
<script>
16-
ball.onmousedown = function(event) {
16+
ball.onmousedown = function(event) {
1717
ball.style.position = 'absolute';
1818
ball.style.zIndex = 1000;
1919
document.body.appendChild(ball);

3-frames-and-windows/03-cross-window-communication/sandbox.view/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<body>
99

10-
<div>The iframe below is has <code>sandbox</code> attribute.</div>
10+
<div>The iframe below has the <code>sandbox</code> attribute.</div>
1111

1212
<iframe sandbox src="sandboxed.html" style="height:60px;width:90%"></iframe>
1313

6-data-storage/02-localstorage/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ localStorage.setItem('now', Date.now());
222222

223223
Web 存储对象 `localStorage``sessionStorage` 允许我们在浏览器中保存键/值对。
224224
- `key``value` 都必须为字符串。
225-
- 存储大小限制为 2MB+,具体取决于浏览器。
225+
- 存储大小限制为 5MB+,具体取决于浏览器。
226226
- 它们不会过期。
227227
- 数据绑定到源(域/端口/协议)。
228228

0 commit comments

Comments
 (0)