From f0c55baab7b82b46630c4238a022e81c7b94d198 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Thu, 15 Oct 2020 13:16:32 +0800 Subject: [PATCH 01/31] FIX: change ; to , --- 1-js/01-getting-started/4-devtools/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/01-getting-started/4-devtools/article.md b/1-js/01-getting-started/4-devtools/article.md index 50926d4f7..08aeaf987 100644 --- a/1-js/01-getting-started/4-devtools/article.md +++ b/1-js/01-getting-started/4-devtools/article.md @@ -8,7 +8,7 @@ To see errors and get a lot of other useful information about scripts, "develope Most developers lean towards Chrome or Firefox for development because those browsers have the best developer tools. Other browsers also provide developer tools, sometimes with special features, but are usually playing "catch-up" to Chrome or Firefox. So most developers have a "favorite" browser and switch to others if a problem is browser-specific. -Developer tools are potent; they have many features. To start, we'll learn how to open them, look at errors, and run JavaScript commands. +Developer tools are potent, they have many features. To start, we'll learn how to open them, look at errors, and run JavaScript commands. ## Google Chrome From fe3ba111bfa8788adadfea9ad008b4ec80e3da4f Mon Sep 17 00:00:00 2001 From: LeviDing Date: Thu, 15 Oct 2020 22:11:10 +0800 Subject: [PATCH 02/31] OPT: change "false" to "falsy" --- 1-js/06-advanced-functions/01-recursion/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/06-advanced-functions/01-recursion/article.md b/1-js/06-advanced-functions/01-recursion/article.md index 320de62f0..3639431da 100644 --- a/1-js/06-advanced-functions/01-recursion/article.md +++ b/1-js/06-advanced-functions/01-recursion/article.md @@ -132,7 +132,7 @@ We can sketch it as: -That's when the function starts to execute. The condition `n == 1` is false, so the flow continues into the second branch of `if`: +That's when the function starts to execute. The condition `n == 1` is falsy, so the flow continues into the second branch of `if`: ```js run function pow(x, n) { From d6f98e1ed69761c3269e6ec44b087ca50c2c7d2a Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Thu, 15 Oct 2020 18:34:19 +0300 Subject: [PATCH 03/31] Fix a possible typo in 1.6.1 --- 1-js/06-advanced-functions/01-recursion/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/06-advanced-functions/01-recursion/article.md b/1-js/06-advanced-functions/01-recursion/article.md index 320de62f0..f23374f60 100644 --- a/1-js/06-advanced-functions/01-recursion/article.md +++ b/1-js/06-advanced-functions/01-recursion/article.md @@ -188,7 +188,7 @@ The new current execution context is on top (and bold), and previous remembered When we finish the subcall -- it is easy to resume the previous context, because it keeps both variables and the exact place of the code where it stopped. ```smart -Here in the picture we use the word "line", as our example there's only one subcall in line, but generally a single line of code may contain multiple subcalls, like `pow(…) + pow(…) + somethingElse(…)`. +Here in the picture we use the word "line", as in our example there's only one subcall in line, but generally a single line of code may contain multiple subcalls, like `pow(…) + pow(…) + somethingElse(…)`. So it would be more precise to say that the execution resumes "immediately after the subcall". ``` From 187e8e13fa9f1ba457f50d00cae272f769fe4769 Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Thu, 15 Oct 2020 18:35:59 +0300 Subject: [PATCH 04/31] Fix a typo in 1.6.1 task solution --- .../06-advanced-functions/01-recursion/02-factorial/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/06-advanced-functions/01-recursion/02-factorial/solution.md b/1-js/06-advanced-functions/01-recursion/02-factorial/solution.md index 59040a2b7..09e511db5 100644 --- a/1-js/06-advanced-functions/01-recursion/02-factorial/solution.md +++ b/1-js/06-advanced-functions/01-recursion/02-factorial/solution.md @@ -1,4 +1,4 @@ -By definition, a factorial is `n!` can be written as `n * (n-1)!`. +By definition, a factorial `n!` can be written as `n * (n-1)!`. In other words, the result of `factorial(n)` can be calculated as `n` multiplied by the result of `factorial(n-1)`. And the call for `n-1` can recursively descend lower, and lower, till `1`. From de8cf9fe5c511b6eb05d22f77a7677158578c217 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Sat, 17 Oct 2020 14:49:29 +0800 Subject: [PATCH 05/31] FIX: delete extra space --- 1-js/05-data-types/05-array-methods/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/05-data-types/05-array-methods/article.md b/1-js/05-data-types/05-array-methods/article.md index ace4c7887..bab880a27 100644 --- a/1-js/05-data-types/05-array-methods/article.md +++ b/1-js/05-data-types/05-array-methods/article.md @@ -743,7 +743,7 @@ These methods are the most used ones, they cover 99% of use cases. But there are The function `fn` is called on each element of the array similar to `map`. If any/all results are `true`, returns `true`, otherwise `false`. - These methods behave sort of like `||` and `&&` operators: if `fn` returns a truthy value, `arr.some()` immediately returns `true` and stops iterating over the rest items; if `fn` returns a falsy value, `arr.every()` immediately returns `false` and stops iterating over the rest items as well. + These methods behave sort of like `||` and `&&` operators: if `fn` returns a truthy value, `arr.some()` immediately returns `true` and stops iterating over the rest items; if `fn` returns a falsy value, `arr.every()` immediately returns `false` and stops iterating over the rest items as well. We can use `every` to compare arrays: ```js run From 2f822c8ec34507de18356556c1e96a56f4beb446 Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Fri, 30 Oct 2020 18:01:51 +0200 Subject: [PATCH 06/31] Fix semicolons in 1.11.1 (Introduction: callbacks) --- 1-js/11-async/01-callbacks/article.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/1-js/11-async/01-callbacks/article.md b/1-js/11-async/01-callbacks/article.md index 9d1a260d5..344d92b74 100644 --- a/1-js/11-async/01-callbacks/article.md +++ b/1-js/11-async/01-callbacks/article.md @@ -146,7 +146,7 @@ loadScript('/my/script.js', function(script) { }); */!* - }) + }); }); ``` @@ -223,7 +223,7 @@ loadScript('1.js', function(error, script) { }); } - }) + }); } }); ``` @@ -256,7 +256,7 @@ loadScript('1.js', function(error, script) { } }); } - }) + }); } }); --> @@ -296,7 +296,7 @@ function step3(error, script) { } else { // ...continue after all scripts are loaded (*) } -}; +} ``` See? It does the same, and there's no deep nesting now because we made every action a separate top-level function. From c3979cdd414c196ac46dfcbd35b0c7009cf043eb Mon Sep 17 00:00:00 2001 From: Osvaldo Dias dos Santos Date: Sat, 31 Oct 2020 05:59:18 +0100 Subject: [PATCH 07/31] Fix typo. --- 9-regular-expressions/02-regexp-character-classes/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/9-regular-expressions/02-regexp-character-classes/article.md b/9-regular-expressions/02-regexp-character-classes/article.md index 7baa6984b..93552a2b0 100644 --- a/9-regular-expressions/02-regexp-character-classes/article.md +++ b/9-regular-expressions/02-regexp-character-classes/article.md @@ -120,7 +120,7 @@ alert( "CS-4".match(regexp) ); // CS-4 alert( "CS 4".match(regexp) ); // CS 4 (space is also a character) ``` -Please note that a dot means "any character", but not the "absense of a character". There must be a character to match it: +Please note that a dot means "any character", but not the "absence of a character". There must be a character to match it: ```js run alert( "CS4".match(/CS.4/) ); // null, no match because there's no character for the dot From 0b6cfc9b1e30ddc56fc3b4b5c3c1cf22efb35e3d Mon Sep 17 00:00:00 2001 From: Kenny John Jacob Date: Sat, 31 Oct 2020 14:44:00 +0530 Subject: [PATCH 08/31] Update article.md --- 5-network/04-fetch-abort/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/5-network/04-fetch-abort/article.md b/5-network/04-fetch-abort/article.md index 6548f81d2..9efadd0ee 100644 --- a/5-network/04-fetch-abort/article.md +++ b/5-network/04-fetch-abort/article.md @@ -65,7 +65,7 @@ fetch(url, { The `fetch` method knows how to work with `AbortController`. It will listen to `abort` events on `signal`. -Now, to to abort, call `controller.abort()`: +Now, to abort, call `controller.abort()`: ```js controller.abort(); From 1236996ba1230fb5b1fdd7f8203d819fd8f9f820 Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Sat, 31 Oct 2020 12:57:05 +0200 Subject: [PATCH 09/31] Fix a typo in 1.11.3 (Promises chaining) --- 1-js/11-async/03-promise-chaining/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/11-async/03-promise-chaining/article.md b/1-js/11-async/03-promise-chaining/article.md index 9f3b60f3a..78d381a94 100644 --- a/1-js/11-async/03-promise-chaining/article.md +++ b/1-js/11-async/03-promise-chaining/article.md @@ -265,7 +265,7 @@ fetch('/article/promise-chaining/user.json') Now let's do something with the loaded user. -For instance, we can make one more requests to GitHub, load the user profile and show the avatar: +For instance, we can make one more request to GitHub, load the user profile and show the avatar: ```js run // Make a request for user.json From d5a88b6b2ad0339c30179ea7146717af5340e336 Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Sat, 31 Oct 2020 18:10:32 +0200 Subject: [PATCH 10/31] Fix semicolons in 1.11.6 (Promisification) --- 1-js/11-async/06-promisify/article.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/1-js/11-async/06-promisify/article.md b/1-js/11-async/06-promisify/article.md index 4ef622546..660e2e357 100644 --- a/1-js/11-async/06-promisify/article.md +++ b/1-js/11-async/06-promisify/article.md @@ -27,11 +27,11 @@ Let's promisify it. The new `loadScriptPromise(src)` function achieves the same let loadScriptPromise = function(src) { return new Promise((resolve, reject) => { loadScript(src, (err, script) => { - if (err) reject(err) + if (err) reject(err); else resolve(script); }); - }) -} + }); +}; // usage: // loadScriptPromise('path/script.js').then(...) @@ -62,7 +62,7 @@ function promisify(f) { f.call(this, ...args); // call the original function }); }; -}; +} // usage: let loadScriptPromise = promisify(loadScript); @@ -94,11 +94,11 @@ function promisify(f, manyArgs = false) { f.call(this, ...args); }); }; -}; +} // usage: f = promisify(f, true); -f(...).then(arrayOfResults => ..., err => ...) +f(...).then(arrayOfResults => ..., err => ...); ``` For more exotic callback formats, like those without `err` at all: `callback(result)`, we can promisify such functions manually without using the helper. From 37c6a31de5b55fc54ab57198a9cc3610947b4f7d Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Sun, 1 Nov 2020 01:45:02 +0200 Subject: [PATCH 11/31] Fix semicolons, remove old note in 1.11.8 --- 1-js/11-async/08-async-await/01-rewrite-async/task.md | 2 +- 1-js/11-async/08-async-await/02-rewrite-async-2/task.md | 4 ++-- 1-js/11-async/08-async-await/article.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/1-js/11-async/08-async-await/01-rewrite-async/task.md b/1-js/11-async/08-async-await/01-rewrite-async/task.md index e2fd375d9..a04b4ff94 100644 --- a/1-js/11-async/08-async-await/01-rewrite-async/task.md +++ b/1-js/11-async/08-async-await/01-rewrite-async/task.md @@ -12,7 +12,7 @@ function loadJson(url) { } else { throw new Error(response.status); } - }) + }); } loadJson('no-such-user.json') diff --git a/1-js/11-async/08-async-await/02-rewrite-async-2/task.md b/1-js/11-async/08-async-await/02-rewrite-async-2/task.md index a5c1c03a2..13d625d2a 100644 --- a/1-js/11-async/08-async-await/02-rewrite-async-2/task.md +++ b/1-js/11-async/08-async-await/02-rewrite-async-2/task.md @@ -1,7 +1,7 @@ # Rewrite "rethrow" with async/await -Below you can find the "rethrow" example from the chapter . Rewrite it using `async/await` instead of `.then/catch`. +Below you can find the "rethrow" example. Rewrite it using `async/await` instead of `.then/catch`. And get rid of the recursion in favour of a loop in `demoGithubUser`: with `async/await` that becomes easy to do. @@ -22,7 +22,7 @@ function loadJson(url) { } else { throw new HttpError(response); } - }) + }); } // Ask for a user name until github returns a valid user diff --git a/1-js/11-async/08-async-await/article.md b/1-js/11-async/08-async-await/article.md index 29bfcaf51..176c691e9 100644 --- a/1-js/11-async/08-async-await/article.md +++ b/1-js/11-async/08-async-await/article.md @@ -156,7 +156,7 @@ class Thenable { // resolve with this.num*2 after 1000ms setTimeout(() => resolve(this.num * 2), 1000); // (*) } -}; +} async function f() { // waits for 1 second, then result becomes 2 From 58d9f752b6238001d9411652c2ac081108588b23 Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Sun, 1 Nov 2020 03:03:36 +0200 Subject: [PATCH 12/31] Fix typo in 1.11.6 (Promisification) --- 1-js/11-async/06-promisify/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/11-async/06-promisify/article.md b/1-js/11-async/06-promisify/article.md index 8c33dc773..3ac963514 100644 --- a/1-js/11-async/06-promisify/article.md +++ b/1-js/11-async/06-promisify/article.md @@ -82,7 +82,7 @@ The code may look a bit complex, but it's essentially the same that we wrote abo A call to `promisify(f)` returns a wrapper around `f` `(*)`. That wrapper returns a promise and forwards the call to the original `f`, tracking the result in the custom callback `(**)`. -Here, `promisiefy` assumes that the original function expects a callback with exactly two arguments `(err, result)`. That's what we encounter most often. Then our custom callback is in exactly the right format, and `promisify` works great for such a case. +Here, `promisify` assumes that the original function expects a callback with exactly two arguments `(err, result)`. That's what we encounter most often. Then our custom callback is in exactly the right format, and `promisify` works great for such a case. But what if the original `f` expects a callback with more arguments `callback(err, res1, res2, ...)`? From 0bdf17e74bbfc8f907741b389d75f31e4f0e1736 Mon Sep 17 00:00:00 2001 From: satyam bansal Date: Sun, 1 Nov 2020 17:59:28 +0530 Subject: [PATCH 13/31] Fix Optional chaining doc --- 1-js/04-object-basics/07-optional-chaining/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/04-object-basics/07-optional-chaining/article.md b/1-js/04-object-basics/07-optional-chaining/article.md index a20ad4480..97fab12eb 100644 --- a/1-js/04-object-basics/07-optional-chaining/article.md +++ b/1-js/04-object-basics/07-optional-chaining/article.md @@ -80,7 +80,7 @@ The optional chaining `?.` stops the evaluation if the part before `?.` is `unde In other words, `value?.prop`: - is the same as `value.prop` if `value` exists, -- otherwise (when `value` is `undefined/null`) it returns that `value`. +- otherwise (when `value` is `undefined/null`) it returns `undefined`. Here's the safe way to access `user.address.street` using `?.`: From 05dfb567867c96e0e0f5e2afc7e15b43faedb2bf Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Sun, 1 Nov 2020 18:59:36 +0200 Subject: [PATCH 14/31] Fix typo, add note in 1.12.2 (Async iteration) --- .../2-async-iterators-generators/article.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/12-generators-iterators/2-async-iterators-generators/article.md b/1-js/12-generators-iterators/2-async-iterators-generators/article.md index 10375f635..00a56b9c3 100644 --- a/1-js/12-generators-iterators/2-async-iterators-generators/article.md +++ b/1-js/12-generators-iterators/2-async-iterators-generators/article.md @@ -301,7 +301,7 @@ Now values come with a delay of 1 second between them. ```smart Technically, we can add both `Symbol.iterator` and `Symbol.asyncIterator` to the object, so it's both synchronously (`for..of`) and asynchronously (`for await..of`) iterable. -In practice though, that would be an weird thing to do. +In practice though, that would be a weird thing to do. ``` ## Real-life example: paginated data @@ -363,7 +363,7 @@ More explanations about how it works: - The initial URL is `https://api.github.com/repos//commits`, and the next page will be in the `Link` header of the response. - The `fetch` method allows us to supply authorization and other headers if needed -- here GitHub requires `User-Agent`. 2. The commits are returned in JSON format. -3. We should get the next page URL from the `Link` header of the response. It has a special format, so we use a regular expression for that. +3. We should get the next page URL from the `Link` header of the response. It has a special format, so we use a regular expression for that (we will lern this feature in [Regular expressions](info:regular-expressions)). - The next page URL may look like `https://api.github.com/repositories/93253246/commits?page=2`. It's generated by GitHub itself. 4. Then we yield the received commits one by one, and when they finish, the next `while(url)` iteration will trigger, making one more request. From ec81513954bfaef3eddc17e9d6e6b0c0a49cf001 Mon Sep 17 00:00:00 2001 From: Will Atwood Mitchell Date: Sun, 1 Nov 2020 14:36:43 -0500 Subject: [PATCH 15/31] Change `var` to `let` in 7.16 regexp-sticky MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 10d1b1f25 added a hint about which word would be found by a certain regexp: "A call to str.match(/\w+/) will find only the first word in the line (var). That’s not it." Unfortunately the result is incorrect: the regexp would find `let`, not `var`. Updating the hint should resolve any confusion. The example has been tested in the console to ensure that the regexp does indeed return `let`. --- 9-regular-expressions/16-regexp-sticky/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/9-regular-expressions/16-regexp-sticky/article.md b/9-regular-expressions/16-regexp-sticky/article.md index 161ce4dd8..373f3453e 100644 --- a/9-regular-expressions/16-regexp-sticky/article.md +++ b/9-regular-expressions/16-regexp-sticky/article.md @@ -13,7 +13,7 @@ E.g. we have a code string `subject:let varName = "value"`, and we need to read We'll look for variable name using regexp `pattern:\w+`. Actually, JavaScript variable names need a bit more complex regexp for accurate matching, but here it doesn't matter. -- A call to `str.match(/\w+/)` will find only the first word in the line (`var`). That's not it. +- A call to `str.match(/\w+/)` will find only the first word in the line (`let`). That's not it. - We can add the flag `pattern:g`. But then the call `str.match(/\w+/g)` will look for all words in the text, while we need one word at position `4`. Again, not what we need. **So, how to search for a regexp exactly at the given position?** From 4e9a33542f138b5ac2f727e3d785ab1cc829a04f Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Sun, 1 Nov 2020 22:54:30 +0200 Subject: [PATCH 16/31] Correct comment in 1.13.1 Strictly speaking, there is no error here, as `typeof` does not produce errors with undefined variables. --- 1-js/13-modules/01-modules-intro/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/13-modules/01-modules-intro/article.md b/1-js/13-modules/01-modules-intro/article.md index e9e1fc249..9afe0fdaa 100644 --- a/1-js/13-modules/01-modules-intro/article.md +++ b/1-js/13-modules/01-modules-intro/article.md @@ -260,7 +260,7 @@ Compare to regular script below: From b83f2d7f1d79988af2011e3f7461eea91645ec7f Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Wed, 4 Nov 2020 20:32:44 +0200 Subject: [PATCH 17/31] Fix typos in 'Proxy and Reflect' --- 1-js/99-js-misc/01-proxy/01-error-nonexisting/solution.md | 2 +- 1-js/99-js-misc/01-proxy/01-error-nonexisting/task.md | 2 +- 1-js/99-js-misc/01-proxy/article.md | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/1-js/99-js-misc/01-proxy/01-error-nonexisting/solution.md b/1-js/99-js-misc/01-proxy/01-error-nonexisting/solution.md index 357a57313..9db69cb2f 100644 --- a/1-js/99-js-misc/01-proxy/01-error-nonexisting/solution.md +++ b/1-js/99-js-misc/01-proxy/01-error-nonexisting/solution.md @@ -19,5 +19,5 @@ function wrap(target) { user = wrap(user); alert(user.name); // John -alert(user.age); // ReferenceError: Property doesn't exist "age" +alert(user.age); // ReferenceError: Property doesn't exist: "age" ``` diff --git a/1-js/99-js-misc/01-proxy/01-error-nonexisting/task.md b/1-js/99-js-misc/01-proxy/01-error-nonexisting/task.md index d7093c0c3..47985e1a7 100644 --- a/1-js/99-js-misc/01-proxy/01-error-nonexisting/task.md +++ b/1-js/99-js-misc/01-proxy/01-error-nonexisting/task.md @@ -27,6 +27,6 @@ user = wrap(user); alert(user.name); // John *!* -alert(user.age); // ReferenceError: Property doesn't exist "age" +alert(user.age); // ReferenceError: Property doesn't exist: "age" */!* ``` diff --git a/1-js/99-js-misc/01-proxy/article.md b/1-js/99-js-misc/01-proxy/article.md index 0711fd33a..b1c351d3a 100644 --- a/1-js/99-js-misc/01-proxy/article.md +++ b/1-js/99-js-misc/01-proxy/article.md @@ -39,7 +39,7 @@ As there are no traps, all operations on `proxy` are forwarded to `target`. As we can see, without any traps, `proxy` is a transparent wrapper around `target`. -![](proxy.svg) +![](proxy.svg) `Proxy` is a special "exotic object". It doesn't have own properties. With an empty `handler` it transparently forwards operations to `target`. @@ -335,7 +335,7 @@ let user = { _password: "secret" }; -alert(user._password); // secret +alert(user._password); // secret ``` Let's use proxies to prevent any access to properties starting with `_`. @@ -376,7 +376,7 @@ user = new Proxy(user, { }, *!* deleteProperty(target, prop) { // to intercept property deletion -*/!* +*/!* if (prop.startsWith('_')) { throw new Error("Access denied"); } else { @@ -437,7 +437,7 @@ user = { ``` -A call to `user.checkPassword()` call gets proxied `user` as `this` (the object before dot becomes `this`), so when it tries to access `this._password`, the `get` trap activates (it triggers on any property read) and throws an error. +A call to `user.checkPassword()` gets proxied `user` as `this` (the object before dot becomes `this`), so when it tries to access `this._password`, the `get` trap activates (it triggers on any property read) and throws an error. So we bind the context of object methods to the original object, `target`, in the line `(*)`. Then their future calls will use `target` as `this`, without any traps. From 422ef44b6ba17ffa0953ec62edd1beae0c03d391 Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Thu, 5 Nov 2020 20:29:52 +0000 Subject: [PATCH 18/31] Fix outdated note in 1.99.04 (Reference Type) Now this chapter is at the end of the general section. --- 1-js/99-js-misc/04-reference-type/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/99-js-misc/04-reference-type/article.md b/1-js/99-js-misc/04-reference-type/article.md index c680c17f9..227253436 100644 --- a/1-js/99-js-misc/04-reference-type/article.md +++ b/1-js/99-js-misc/04-reference-type/article.md @@ -93,7 +93,7 @@ Reference type is a special "intermediary" internal type, with the purpose to pa Any other operation like assignment `hi = user.hi` discards the reference type as a whole, takes the value of `user.hi` (a function) and passes it on. So any further operation "loses" `this`. -So, as the result, the value of `this` is only passed the right way if the function is called directly using a dot `obj.method()` or square brackets `obj['method']()` syntax (they do the same here). Later in this tutorial, we will learn various ways to solve this problem such as [func.bind()](/bind#solution-2-bind). +So, as the result, the value of `this` is only passed the right way if the function is called directly using a dot `obj.method()` or square brackets `obj['method']()` syntax (they do the same here). There are various ways to solve this problem such as [func.bind()](/bind#solution-2-bind). ## Summary From e25caaec2e82ab781989f3c3724c7eeb5a7d302c Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Thu, 5 Nov 2020 20:37:29 +0000 Subject: [PATCH 19/31] Correct solution explanation in 1.99.04 (Reference Type) --- 1-js/99-js-misc/04-reference-type/3-why-this/solution.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/99-js-misc/04-reference-type/3-why-this/solution.md b/1-js/99-js-misc/04-reference-type/3-why-this/solution.md index 31ea4ff88..e4ee78748 100644 --- a/1-js/99-js-misc/04-reference-type/3-why-this/solution.md +++ b/1-js/99-js-misc/04-reference-type/3-why-this/solution.md @@ -5,7 +5,7 @@ Here's the explanations. 2. The same, parentheses do not change the order of operations here, the dot is first anyway. -3. Here we have a more complex call `(expression).method()`. The call works as if it were split into two lines: +3. Here we have a more complex call `(expression)()`. The call works as if it were split into two lines: ```js no-beautify f = obj.go; // calculate the expression @@ -14,7 +14,7 @@ Here's the explanations. Here `f()` is executed as a function, without `this`. -4. The similar thing as `(3)`, to the left of the dot `.` we have an expression. +4. The similar thing as `(3)`, to the left of the parentheses `()` we have an expression. To explain the behavior of `(3)` and `(4)` we need to recall that property accessors (dot or square brackets) return a value of the Reference Type. From bf3c878eb02603a049c580c54e4f2e496472160c Mon Sep 17 00:00:00 2001 From: Vse Mozhe Buty Date: Thu, 5 Nov 2020 20:41:07 +0000 Subject: [PATCH 20/31] Fix link in 2.1.5 (Node properties...) --- 2-ui/1-document/05-basic-dom-node-properties/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-ui/1-document/05-basic-dom-node-properties/article.md b/2-ui/1-document/05-basic-dom-node-properties/article.md index cea166e8d..fc3bf6525 100644 --- a/2-ui/1-document/05-basic-dom-node-properties/article.md +++ b/2-ui/1-document/05-basic-dom-node-properties/article.md @@ -198,7 +198,7 @@ In XML mode the case is kept "as is". Nowadays XML mode is rarely used. ## innerHTML: the contents -The [innerHTML](https://w3c.github.io/DOM-Parsing/#widl-Element-innerHTML) property allows to get the HTML inside the element as a string. +The [innerHTML](https://w3c.github.io/DOM-Parsing/#the-innerhtml-mixin) property allows to get the HTML inside the element as a string. We can also modify it. So it's one of the most powerful ways to change the page. From bd239300444cad0e39a4d5f1feb501d784aece69 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Mon, 9 Nov 2020 22:29:54 +0800 Subject: [PATCH 21/31] Update article.md --- 2-ui/5-loading/02-script-async-defer/article.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/2-ui/5-loading/02-script-async-defer/article.md b/2-ui/5-loading/02-script-async-defer/article.md index 45f507d79..2f9d45e9c 100644 --- a/2-ui/5-loading/02-script-async-defer/article.md +++ b/2-ui/5-loading/02-script-async-defer/article.md @@ -37,7 +37,7 @@ Luckily, there are two `