From 7953ccb712d636cfda900fe7c25a7b05d1a11c72 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Sun, 19 Jul 2020 00:19:54 +0800 Subject: [PATCH] update to 2020-07-18 --- 1-js/02-first-steps/10-ifelse/article.md | 2 +- 1-js/02-first-steps/12-nullish-coalescing-operator/article.md | 2 +- .../02-coding-style/1-style-errors/solution.md | 4 ++-- 1-js/04-object-basics/03-garbage-collection/article.md | 2 +- 1-js/04-object-basics/08-symbol/article.md | 2 +- 1-js/08-prototypes/04-prototype-methods/article.md | 4 ++-- 1-js/09-classes/06-instanceof/article.md | 2 +- 1-js/11-async/04-promise-error-handling/article.md | 2 +- .../4-mouse-drag-and-drop/ball.view/index.html | 2 +- .../03-cross-window-communication/sandbox.view/index.html | 2 +- 6-data-storage/02-localstorage/article.md | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/1-js/02-first-steps/10-ifelse/article.md b/1-js/02-first-steps/10-ifelse/article.md index 39803f3881..b5537f79d3 100644 --- a/1-js/02-first-steps/10-ifelse/article.md +++ b/1-js/02-first-steps/10-ifelse/article.md @@ -1,4 +1,4 @@ -# 条件运算符:if 和 '?' +# 条件分支:if 和 '?' 有时我们需要根据不同条件执行不同的操作。 diff --git a/1-js/02-first-steps/12-nullish-coalescing-operator/article.md b/1-js/02-first-steps/12-nullish-coalescing-operator/article.md index 7500079611..80dace902b 100644 --- a/1-js/02-first-steps/12-nullish-coalescing-operator/article.md +++ b/1-js/02-first-steps/12-nullish-coalescing-operator/article.md @@ -68,7 +68,7 @@ alert(height ?? 100); // 0 ## 优先级 -`??` 运算符的优先级相当低:在 [MDN table](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table) 中为 `7`。 +`??` 运算符的优先级相当低:在 [MDN table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table) 中为 `5`。 因此,`??` 在大多数其他运算之后,但在 `=` 和 `?` 之前进行运算。 diff --git a/1-js/03-code-quality/02-coding-style/1-style-errors/solution.md b/1-js/03-code-quality/02-coding-style/1-style-errors/solution.md index 818b13c2a1..2297848813 100644 --- a/1-js/03-code-quality/02-coding-style/1-style-errors/solution.md +++ b/1-js/03-code-quality/02-coding-style/1-style-errors/solution.md @@ -12,7 +12,7 @@ function pow(x,n) // <- 参数之间没有空格 let x=prompt("x?",''), n=prompt("n?",'') // <-- 从技术的角度来看是可以的, // 但是拆分成 2 行会更好,并且这里也缺了空格和分号 ; -if (n<0) // <- (n < 0) 里面没有空格,并且应该在本行上面加一个空行 +if (n<=0) // <- (n <= 0) 里面没有空格,并且应该在本行上面加一个空行 { // <- 花括号独占了一行 // 下面的一行代码太长了,可以将其拆分成 2 行以提高可读性 alert(`Power ${n} is not supported, please enter an integer number greater than zero`); @@ -39,7 +39,7 @@ function pow(x, n) { let x = prompt("x?", ""); let n = prompt("n?", ""); -if (n < 0) { +if (n <= 0) { alert(`Power ${n} is not supported, please enter an integer number greater than zero`); } else { diff --git a/1-js/04-object-basics/03-garbage-collection/article.md b/1-js/04-object-basics/03-garbage-collection/article.md index ce11fc79a4..23ac32848d 100644 --- a/1-js/04-object-basics/03-garbage-collection/article.md +++ b/1-js/04-object-basics/03-garbage-collection/article.md @@ -23,7 +23,7 @@ JavaScript 中主要的内存管理概念是 **可达性**。 2. 如果一个值可以通过引用或引用链从根访问任何其他值,则认为该值是可达的。 - 比方说,如果局部变量中有一个对象,并且该对象有一个属性引用了另一个对象,则该对象被认为是可达的。而且它引用的内容也是可达的。下面是详细的例子。 + 比方说,如果全局变量中有一个对象,并且该对象有一个属性引用了另一个对象,则该对象被认为是可达的。而且它引用的内容也是可达的。下面是详细的例子。 在 JavaScript 引擎中有一个被称作 [垃圾回收器](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) 的东西在后台执行。它监控着所有对象的状态,并删除掉那些已经不可达的。 diff --git a/1-js/04-object-basics/08-symbol/article.md b/1-js/04-object-basics/08-symbol/article.md index 2d923d6ed6..e482f2f5c2 100644 --- a/1-js/04-object-basics/08-symbol/article.md +++ b/1-js/04-object-basics/08-symbol/article.md @@ -133,7 +133,7 @@ let id = Symbol("id"); let user = { name: "John", *!* - [id]: 123 // 而不是 "id:123" + [id]: 123 // 而不是 "id":123 */!* }; ``` diff --git a/1-js/08-prototypes/04-prototype-methods/article.md b/1-js/08-prototypes/04-prototype-methods/article.md index 36868c57ad..c9cdfbb613 100644 --- a/1-js/08-prototypes/04-prototype-methods/article.md +++ b/1-js/08-prototypes/04-prototype-methods/article.md @@ -7,7 +7,7 @@ 现代的方法有: -- [Object.create(proto[, descriptors])](mdn:js/Object/create) —— 利用给定的 `proto` 作为 `[[Prototype]]` 和可选的属性描述来创建一个空对象。 +- [Object.create(proto, [descriptors])](mdn:js/Object/create) —— 利用给定的 `proto` 作为 `[[Prototype]]` 和可选的属性描述来创建一个空对象。 - [Object.getPrototypeOf(obj)](mdn:js/Object/getPrototypeOf) —— 返回对象 `obj` 的 `[[Prototype]]`。 - [Object.setPrototypeOf(obj, proto)](mdn:js/Object/setPrototypeOf) —— 将对象 `obj` 的 `[[Prototype]]` 设置为 `proto`。 @@ -175,7 +175,7 @@ alert(Object.keys(chineseDictionary)); // hello,bye 设置和直接访问原型的现代方法有: -- [Object.create(proto[, descriptors])](mdn:js/Object/create) —— 利用给定的 `proto` 作为 `[[Prototype]]`(可以是 `null`)和可选的属性描述来创建一个空对象。 +- [Object.create(proto, [descriptors])](mdn:js/Object/create) —— 利用给定的 `proto` 作为 `[[Prototype]]`(可以是 `null`)和可选的属性描述来创建一个空对象。 - [Object.getPrototypeOf(obj)](mdn:js/Object/getPrototypeOf) —— 返回对象 `obj` 的 `[[Prototype]]`(与 `__proto__` 的 getter 相同)。 - [Object.setPrototypeOf(obj, proto)](mdn:js/Object/setPrototypeOf) —— 将对象 `obj` 的 `[[Prototype]]` 设置为 `proto`(与 `__proto__` 的 setter 相同)。 diff --git a/1-js/09-classes/06-instanceof/article.md b/1-js/09-classes/06-instanceof/article.md index b6ad87f37d..118baff90a 100644 --- a/1-js/09-classes/06-instanceof/article.md +++ b/1-js/09-classes/06-instanceof/article.md @@ -190,7 +190,7 @@ alert( {}.toString.call(user) ); // [object User] ```js run // 特定于环境的对象和类的 toStringTag: -alert( window[Symbol.toStringTag]); // window +alert( window[Symbol.toStringTag]); // Window alert( XMLHttpRequest.prototype[Symbol.toStringTag] ); // XMLHttpRequest alert( {}.toString.call(window) ); // [object Window] diff --git a/1-js/11-async/04-promise-error-handling/article.md b/1-js/11-async/04-promise-error-handling/article.md index 43dc545fb6..a0344edd2f 100644 --- a/1-js/11-async/04-promise-error-handling/article.md +++ b/1-js/11-async/04-promise-error-handling/article.md @@ -122,7 +122,7 @@ new Promise((resolve, reject) => { 在下面的例子中,我们可以看到 `.catch` 的另一种情况。`(*)` 行的处理程序(handler)捕获了 error,但无法处理它(例如,它只知道如何处理 `URIError`),所以它将其再次抛出: ```js run -// 执行流:catch -> catch -> then +// 执行流:catch -> catch new Promise((resolve, reject) => { throw new Error("Whoops!"); diff --git a/2-ui/3-event-details/4-mouse-drag-and-drop/ball.view/index.html b/2-ui/3-event-details/4-mouse-drag-and-drop/ball.view/index.html index 36219e303b..8751c70ad2 100644 --- a/2-ui/3-event-details/4-mouse-drag-and-drop/ball.view/index.html +++ b/2-ui/3-event-details/4-mouse-drag-and-drop/ball.view/index.html @@ -13,7 +13,7 @@