From 6df0982d84e649c707a0c3059f677e493db8f329 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Fri, 13 Nov 2020 20:22:16 +0800 Subject: [PATCH 01/17] FIX: minor typo error --- 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 9efadd0e..642190b2 100644 --- a/5-network/04-fetch-abort/article.md +++ b/5-network/04-fetch-abort/article.md @@ -26,7 +26,7 @@ When `abort()` is called: Generally, we have two parties in the process: 1. The one that performs an cancelable operation, it sets a listener on `controller.signal`. -2. The one one that cancels: it calls `controller.abort()` when needed. +2. The one that cancels: it calls `controller.abort()` when needed. Here's the full example (without `fetch` yet): From 806e3710e5aabdac87791b2a2c97b0635f4f9173 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Fri, 13 Nov 2020 20:29:51 +0800 Subject: [PATCH 02/17] 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 642190b2..32f7a173 100644 --- a/5-network/04-fetch-abort/article.md +++ b/5-network/04-fetch-abort/article.md @@ -50,7 +50,7 @@ As we can see, `AbortController` is just a means to pass `abort` events when `ab We could implement same kind of event listening in our code on our own, without `AbortController` object at all. -But what's valuable is that `fetch` knows how to work with `AbortController` object, it's integrated with it. +But what's valuable is that `fetch` knows how to work with `AbortController` object, it's integrated with it. ## Using with fetch From fb43e39bd409d7d9d9f5e5c5486e4a220dc277df Mon Sep 17 00:00:00 2001 From: LeviDing Date: Fri, 13 Nov 2020 22:53:12 +0800 Subject: [PATCH 03/17] Update article.md --- 5-network/06-fetch-api/article.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/5-network/06-fetch-api/article.md b/5-network/06-fetch-api/article.md index 413aa47b..20e26f7a 100644 --- a/5-network/06-fetch-api/article.md +++ b/5-network/06-fetch-api/article.md @@ -217,8 +217,8 @@ Normally, when a document is unloaded, all associated network requests are abort It has a few limitations: -- We can't send megabytes: the body limit for `keepalive` requests is 64kb. +- We can't send megabytes: the body limit for `keepalive` requests is 64KB. - If we need to gather a lot of statistics about the visit, we should send it out regularly in packets, so that there won't be a lot left for the last `onunload` request. - - This limit applies to all `keepalive` requests together. In other words, we can perform multiple `keepalive` requests in parallel, but the sum of their body lengths should not exceed 64kb. + - This limit applies to all `keepalive` requests together. In other words, we can perform multiple `keepalive` requests in parallel, but the sum of their body lengths should not exceed 64KB. - We can't handle the server response if the document is unloaded. So in our example `fetch` will succeed due to `keepalive`, but subsequent functions won't work. - In most cases, such as sending out statistics, it's not a problem, as server just accepts the data and usually sends an empty response to such requests. From d9775827518e229938770fc2b44a63b444e80bf6 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Fri, 13 Nov 2020 23:03:44 +0800 Subject: [PATCH 04/17] Update article.md --- 5-network/06-fetch-api/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/5-network/06-fetch-api/article.md b/5-network/06-fetch-api/article.md index 20e26f7a..52856bb9 100644 --- a/5-network/06-fetch-api/article.md +++ b/5-network/06-fetch-api/article.md @@ -220,5 +220,5 @@ It has a few limitations: - We can't send megabytes: the body limit for `keepalive` requests is 64KB. - If we need to gather a lot of statistics about the visit, we should send it out regularly in packets, so that there won't be a lot left for the last `onunload` request. - This limit applies to all `keepalive` requests together. In other words, we can perform multiple `keepalive` requests in parallel, but the sum of their body lengths should not exceed 64KB. -- We can't handle the server response if the document is unloaded. So in our example `fetch` will succeed due to `keepalive`, but subsequent functions won't work. +- We can't handle the server response if the document is unloaded. So in our example `fetch` will succeed due to `keepalive`, but subsequent functions won't work. - In most cases, such as sending out statistics, it's not a problem, as server just accepts the data and usually sends an empty response to such requests. From ee2bc1c6bdc8013ab45ad78e732ebea3dd1d3686 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Sat, 14 Nov 2020 00:26:50 +0800 Subject: [PATCH 05/17] Update article.md --- 5-network/10-long-polling/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/5-network/10-long-polling/article.md b/5-network/10-long-polling/article.md index 02d21d7a..be367cee 100644 --- a/5-network/10-long-polling/article.md +++ b/5-network/10-long-polling/article.md @@ -70,7 +70,7 @@ As you can see, `subscribe` function makes a fetch, then waits for the response, ```warn header="Server should be ok with many pending connections" The server architecture must be able to work with many pending connections. -Certain server architectures run one process per connection; resulting in there being as many processes as there are connections, while each process consumes quite a bit of memory. So, too many connections will just consume it all. +Certain server architectures run one process per connection, resulting in there being as many processes as there are connections, while each process consumes quite a bit of memory. So, too many connections will just consume it all. That's often the case for backends written in languages like PHP and Ruby. From 7a67741a9b6dc35278829d7196721dc769e2b30a Mon Sep 17 00:00:00 2001 From: LeviDing Date: Sun, 15 Nov 2020 19:42:42 +0800 Subject: [PATCH 06/17] Update article.md --- 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 97fab12e..6f9f01cf 100644 --- a/1-js/04-object-basics/07-optional-chaining/article.md +++ b/1-js/04-object-basics/07-optional-chaining/article.md @@ -9,7 +9,7 @@ The optional chaining `?.` is a safe way to access nested object properties, eve If you've just started to read the tutorial and learn JavaScript, maybe the problem hasn't touched you yet, but it's quite common. -As an example, let's say we have `user` objects that hold the information about our users. +As an example, let's say we have `user` objects that hold the information about our users. Most of our users have addresses in `user.address` property, with the street `user.address.street`, but some did not provide them. From 75e10e203e62e61deef15dc730299dd86bbcad8d Mon Sep 17 00:00:00 2001 From: LeviDing Date: Sun, 15 Nov 2020 20:09:54 +0800 Subject: [PATCH 07/17] Update article.md --- 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 6f9f01cf..e66d86ac 100644 --- a/1-js/04-object-basics/07-optional-chaining/article.md +++ b/1-js/04-object-basics/07-optional-chaining/article.md @@ -21,7 +21,7 @@ let user = {}; // a user without "address" property alert(user.address.street); // Error! ``` -That's the expected result. JavaScript works like this. As `user.address` is `undefined`, an attempt to get `user.address.street` fails with an error. +That's the expected result. JavaScript works like this. As `user.address` is `undefined`, an attempt to get `user.address.street` fails with an error. In many practical cases we'd prefer to get `undefined` instead of an error here (meaning "no street"). From cb62d6d867dd5917cc39720c5f0ba2a15a18a7e7 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Sun, 15 Nov 2020 21:19:03 +0800 Subject: [PATCH 08/17] Update article.md --- 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 e66d86ac..deb0e5a8 100644 --- a/1-js/04-object-basics/07-optional-chaining/article.md +++ b/1-js/04-object-basics/07-optional-chaining/article.md @@ -56,7 +56,7 @@ let user = {}; // user has no address alert(user.address ? user.address.street ? user.address.street.name : null : null); ``` -That's just awful, one may even have problems understanding such code. +That's just awful, one may even have problems understanding such code. Don't even care to, as there's a better way to write it, using the `&&` operator: From a39f437677b95d145dfe862d3b19bf7113a8fc22 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Sun, 15 Nov 2020 21:46:06 +0800 Subject: [PATCH 09/17] Update article.md --- 1-js/05-data-types/08-weakmap-weakset/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/05-data-types/08-weakmap-weakset/article.md b/1-js/05-data-types/08-weakmap-weakset/article.md index 178a4e23..5cfd6b3e 100644 --- a/1-js/05-data-types/08-weakmap-weakset/article.md +++ b/1-js/05-data-types/08-weakmap-weakset/article.md @@ -30,7 +30,7 @@ let array = [ john ]; john = null; // overwrite the reference *!* -// the object previously referenced by john is stored inside the array +// the object previously referenced by john is stored inside the array // therefore it won't be garbage-collected // we can get it as array[0] */!* From 5b63e81e4e2d7ce48bb040fc7951942cfb585c84 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Sun, 15 Nov 2020 22:12:00 +0800 Subject: [PATCH 10/17] Update article.md --- 1-js/08-prototypes/01-prototype-inheritance/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/08-prototypes/01-prototype-inheritance/article.md b/1-js/08-prototypes/01-prototype-inheritance/article.md index cd4b94d3..1b001163 100644 --- a/1-js/08-prototypes/01-prototype-inheritance/article.md +++ b/1-js/08-prototypes/01-prototype-inheritance/article.md @@ -12,7 +12,7 @@ In JavaScript, objects have a special hidden property `[[Prototype]]` (as named ![prototype](object-prototype-empty.svg) -When we read a property from `object`, and it's missing, JavaScript automatically takes it from the prototype. In programming, such thing is called "prototypal inheritance". And soon we'll study many examples of such inheritance, as well as cooler language features built upon it. +When we read a property from `object`, and it's missing, JavaScript automatically takes it from the prototype. In programming, such thing is called "prototypal inheritance". And soon we'll study many examples of such inheritance, as well as cooler language features built upon it. The property `[[Prototype]]` is internal and hidden, but there are many ways to set it. From 358c38988d8573cbed7c61992a6be5844f0de8d0 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Sun, 15 Nov 2020 22:23:11 +0800 Subject: [PATCH 11/17] Update article.md --- 1-js/08-prototypes/01-prototype-inheritance/article.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/08-prototypes/01-prototype-inheritance/article.md b/1-js/08-prototypes/01-prototype-inheritance/article.md index 1b001163..2a46a978 100644 --- a/1-js/08-prototypes/01-prototype-inheritance/article.md +++ b/1-js/08-prototypes/01-prototype-inheritance/article.md @@ -133,11 +133,11 @@ Also it may be obvious, but still: there can be only one `[[Prototype]]`. An obj ```smart header="`__proto__` is a historical getter/setter for `[[Prototype]]`" -It's a common mistake of novice developers not to know the difference between these two. +It's a common mistake of novice developers not to know the difference between these two. Please note that `__proto__` is *not the same* as the internal `[[Prototype]]` property. It's a getter/setter for `[[Prototype]]`. Later we'll see situations where it matters, for now let's just keep it in mind, as we build our understanding of JavaScript language. -The `__proto__` property is a bit outdated. It exists for historical reasons, modern JavaScript suggests that we should use `Object.getPrototypeOf/Object.setPrototypeOf` functions instead that get/set the prototype. We'll also cover these functions later. +The `__proto__` property is a bit outdated. It exists for historical reasons, modern JavaScript suggests that we should use `Object.getPrototypeOf/Object.setPrototypeOf` functions instead that get/set the prototype. We'll also cover these functions later. By the specification, `__proto__` must only be supported by browsers. In fact though, all environments including server-side support `__proto__`, so we're quite safe using it. From 80eb70fd90946e8b4f26196a7d5f61265f39ab0b Mon Sep 17 00:00:00 2001 From: LeviDing Date: Sun, 15 Nov 2020 22:27:03 +0800 Subject: [PATCH 12/17] Update article.md --- 1-js/08-prototypes/01-prototype-inheritance/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/08-prototypes/01-prototype-inheritance/article.md b/1-js/08-prototypes/01-prototype-inheritance/article.md index 2a46a978..cfec0568 100644 --- a/1-js/08-prototypes/01-prototype-inheritance/article.md +++ b/1-js/08-prototypes/01-prototype-inheritance/article.md @@ -135,7 +135,7 @@ Also it may be obvious, but still: there can be only one `[[Prototype]]`. An obj ```smart header="`__proto__` is a historical getter/setter for `[[Prototype]]`" It's a common mistake of novice developers not to know the difference between these two. -Please note that `__proto__` is *not the same* as the internal `[[Prototype]]` property. It's a getter/setter for `[[Prototype]]`. Later we'll see situations where it matters, for now let's just keep it in mind, as we build our understanding of JavaScript language. +Please note that `__proto__` is *not the same* as the internal `[[Prototype]]` property. It's a getter/setter for `[[Prototype]]`. Later we'll see situations where it matters, for now let's just keep it in mind, as we build our understanding of JavaScript language. The `__proto__` property is a bit outdated. It exists for historical reasons, modern JavaScript suggests that we should use `Object.getPrototypeOf/Object.setPrototypeOf` functions instead that get/set the prototype. We'll also cover these functions later. From adf83c64b7e0162ec09f3afe53e98e8ce5a8e0b3 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Mon, 16 Nov 2020 00:32:55 +0800 Subject: [PATCH 13/17] Update article.md --- .../2-async-iterators-generators/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 00a56b9c..072e1047 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 @@ -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 (we will lern this feature in [Regular expressions](info:regular-expressions)). +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 learn 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 9b3b10f507d04059851c6fa39e83b9085d783cb2 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Mon, 16 Nov 2020 13:33:19 +0800 Subject: [PATCH 14/17] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8d7ce909..8624e8ea 100755 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ We'd also like to collaborate on the tutorial with other people. Something's wrong? A topic is missing? Explain it to people, add as PR 👏 -**You can edit the text in any editor.** The tutorial uses enhanced "markdown" format, easy to grasp. And if you want to see how it looks on-site, there's a server to run the tutorial locally at . +**You can edit the text in any editor.** The tutorial uses enhanced "markdown" format, easy to grasp. And if you want to see how it looks on-site, there's a server to run the tutorial locally at . The list of contributors is available at . @@ -35,5 +35,5 @@ Each of these files starts from the `# Main header`. It's very easy to add something new. --- -♥ +♥ Ilya Kantor @iliakan From 6db57d9494c2a7ca7793dc96378279d481b74a29 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Mon, 16 Nov 2020 15:53:33 +0800 Subject: [PATCH 15/17] Update article.md --- 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 ac949989..1d81b31a 100644 --- a/1-js/11-async/06-promisify/article.md +++ b/1-js/11-async/06-promisify/article.md @@ -50,7 +50,7 @@ As we can see, the new function is a wrapper around the original `loadScript` fu Now `loadScriptPromise` fits well in promise-based code. If we like promises more than callbacks (and soon we'll see more reasons for that), then we will use it instead. -In practice we may need to promisify more than one function, so it makes sense to use a helper. +In practice we may need to promisify more than one function, so it makes sense to use a helper. We'll call it `promisify(f)`: it accepts a to-promisify function `f` and returns a wrapper function. From 15780b3a2456174d36d9dec0e657a176ad817466 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Tue, 17 Nov 2020 20:58:33 +0800 Subject: [PATCH 16/17] Update task.md --- .../09-call-apply-decorators/03-debounce/task.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/06-advanced-functions/09-call-apply-decorators/03-debounce/task.md b/1-js/06-advanced-functions/09-call-apply-decorators/03-debounce/task.md index 347a5e64..5b0fcc5f 100644 --- a/1-js/06-advanced-functions/09-call-apply-decorators/03-debounce/task.md +++ b/1-js/06-advanced-functions/09-call-apply-decorators/03-debounce/task.md @@ -21,9 +21,9 @@ Here's the code for it (uses the debounce decorator from the [Lodash library](ht ```js let f = _.debounce(alert, 1000); -f("a"); +f("a"); setTimeout( () => f("b"), 200); -setTimeout( () => f("c"), 500); +setTimeout( () => f("c"), 500); // debounced function waits 1000ms after the last call and then runs: alert("c") ``` From 149f63ed203b0079f32252b60ebc414301988ab7 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Wed, 18 Nov 2020 10:37:38 +0800 Subject: [PATCH 17/17] FIX: minor typo error, missing "alert( " --- .../10-regexp-greedy-and-lazy/1-lazy-greedy/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/9-regular-expressions/10-regexp-greedy-and-lazy/1-lazy-greedy/task.md b/9-regular-expressions/10-regexp-greedy-and-lazy/1-lazy-greedy/task.md index b46f5591..596f61a4 100644 --- a/9-regular-expressions/10-regexp-greedy-and-lazy/1-lazy-greedy/task.md +++ b/9-regular-expressions/10-regexp-greedy-and-lazy/1-lazy-greedy/task.md @@ -3,5 +3,5 @@ What's the match here? ```js -"123 456".match(/\d+? \d+?/g) ); // ? +alert( "123 456".match(/\d+? \d+?/g) ); // ? ```