diff --git a/1-js/11-async/01-callbacks/article.md b/1-js/11-async/01-callbacks/article.md index af38241e..c2f67c6c 100644 --- a/1-js/11-async/01-callbacks/article.md +++ b/1-js/11-async/01-callbacks/article.md @@ -223,6 +223,30 @@ As calls become more nested, the code becomes deeper and increasingly more diffi That's sometimes called "callback hell" or "pyramid of doom." + +  The "pyramid" of nested calls grows to the right with every asynchronous action. Soon it spirals out of control. diff --git a/1-js/11-async/01-callbacks/callback-hell.svg b/1-js/11-async/01-callbacks/callback-hell.svg index eaf125a9..740f6506 100644 --- a/1-js/11-async/01-callbacks/callback-hell.svg +++ b/1-js/11-async/01-callbacks/callback-hell.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/1-js/12-generators-iterators/1-generators/article.md b/1-js/12-generators-iterators/1-generators/article.md index 84f9228f..44472b96 100644 --- a/1-js/12-generators-iterators/1-generators/article.md +++ b/1-js/12-generators-iterators/1-generators/article.md @@ -239,8 +239,8 @@ function* generateSequence(start, end) { Now we'd like to reuse it for generation of a more complex sequence: - first, digits `0..9` (with character codes 48..57), -- followed by alphabet letters `a..z` (character codes 65..90) -- followed by uppercased letters `A..Z` (character codes 97..122) +- followed by alphabet letters `A..Z` (character codes 65..90) +- followed by uppercased letters `a..z` (character codes 97..122) We can use this sequence e.g. to create passwords by selecting characters from it (could add syntax characters as well), but let's generate it first. 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 8be14c7e..94d6e281 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 @@ -283,7 +283,7 @@ for await (let commit of fetchCommits(repo)) { } ``` -We'd like a call, like `fetchCommits(repo)` to get commits for us, making requests whenever needed. And let it care about all pagination stuff, for us it'll be a simple `for await..of`. +We'd like to make a function `fetchCommits(repo)` that gets commits for us, making requests whenever needed. And let it care about all pagination stuff, for us it'll be a simple `for await..of`. With async generators that's pretty easy to implement: @@ -361,4 +361,4 @@ In web-development we often meet streams of data, when it flows chunk-by-chunk. We can use async generators to process such data, but it's also worth to mention that there's also another API called Streams, that provides special interfaces to work with such streams, to transform the data and to pass it from one stream to another (e.g. download from one place and immediately send elsewhere). -Streams API is not a part of JavaScript language standard. +Streams API is not a part of JavaScript language standard. diff --git a/2-ui/99-ui-misc/02-selection-range/range-example-p-0-1.svg b/2-ui/99-ui-misc/02-selection-range/range-example-p-0-1.svg index e8566885..4550c373 100644 --- a/2-ui/99-ui-misc/02-selection-range/range-example-p-0-1.svg +++ b/2-ui/99-ui-misc/02-selection-range/range-example-p-0-1.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/2-ui/99-ui-misc/02-selection-range/range-example-p-1-3.svg b/2-ui/99-ui-misc/02-selection-range/range-example-p-1-3.svg index 9d796c7e..dd19679c 100644 --- a/2-ui/99-ui-misc/02-selection-range/range-example-p-1-3.svg +++ b/2-ui/99-ui-misc/02-selection-range/range-example-p-1-3.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/2-ui/99-ui-misc/02-selection-range/range-example-p-2-b-3-range.svg b/2-ui/99-ui-misc/02-selection-range/range-example-p-2-b-3-range.svg index d3abd8d8..e7bdb2a0 100644 --- a/2-ui/99-ui-misc/02-selection-range/range-example-p-2-b-3-range.svg +++ b/2-ui/99-ui-misc/02-selection-range/range-example-p-2-b-3-range.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/2-ui/99-ui-misc/02-selection-range/range-example-p-2-b-3.svg b/2-ui/99-ui-misc/02-selection-range/range-example-p-2-b-3.svg index ba9f1f1c..fd058beb 100644 --- a/2-ui/99-ui-misc/02-selection-range/range-example-p-2-b-3.svg +++ b/2-ui/99-ui-misc/02-selection-range/range-example-p-2-b-3.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/2-ui/99-ui-misc/02-selection-range/selection-direction-backward.svg b/2-ui/99-ui-misc/02-selection-range/selection-direction-backward.svg index 06df79be..3e7eb7f1 100644 --- a/2-ui/99-ui-misc/02-selection-range/selection-direction-backward.svg +++ b/2-ui/99-ui-misc/02-selection-range/selection-direction-backward.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/2-ui/99-ui-misc/02-selection-range/selection-direction-forward.svg b/2-ui/99-ui-misc/02-selection-range/selection-direction-forward.svg index 74da3c79..7fb3cbe0 100644 --- a/2-ui/99-ui-misc/02-selection-range/selection-direction-forward.svg +++ b/2-ui/99-ui-misc/02-selection-range/selection-direction-forward.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/4-binary/01-arraybuffer-binary-arrays/8bit-integer-256.svg b/4-binary/01-arraybuffer-binary-arrays/8bit-integer-256.svg index 38085b4a..89ae9640 100644 --- a/4-binary/01-arraybuffer-binary-arrays/8bit-integer-256.svg +++ b/4-binary/01-arraybuffer-binary-arrays/8bit-integer-256.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/4-binary/01-arraybuffer-binary-arrays/8bit-integer-257.svg b/4-binary/01-arraybuffer-binary-arrays/8bit-integer-257.svg index cad97574..c7b74cd6 100644 --- a/4-binary/01-arraybuffer-binary-arrays/8bit-integer-257.svg +++ b/4-binary/01-arraybuffer-binary-arrays/8bit-integer-257.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/4-binary/03-blob/blob.svg b/4-binary/03-blob/blob.svg index 9542160a..b1cf6fcc 100644 --- a/4-binary/03-blob/blob.svg +++ b/4-binary/03-blob/blob.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/5-network/07-url/url-object.svg b/5-network/07-url/url-object.svg index 6484fbb5..80da6fec 100644 --- a/5-network/07-url/url-object.svg +++ b/5-network/07-url/url-object.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/5-network/08-xmlhttprequest/article.md b/5-network/08-xmlhttprequest/article.md index fac27203..f150d47c 100644 --- a/5-network/08-xmlhttprequest/article.md +++ b/5-network/08-xmlhttprequest/article.md @@ -6,7 +6,7 @@ Despite of having the word "XML" in its name, it can operate on any data, not on Right now, there's another, more modern method `fetch`, that somewhat deprecates `XMLHttpRequest`. -In modern web-development `XMLHttpRequest` may be used for three reasons: +In modern web-development `XMLHttpRequest` is used for three reasons: 1. Historical reasons: we need to support existing scripts with `XMLHttpRequest`. 2. We need to support old browsers, and don't want polyfills (e.g. to keep scripts tiny). @@ -51,7 +51,7 @@ To do the request, we need 3 steps: Some request methods like `GET` do not have a body. And some of them like `POST` use `body` to send the data to the server. We'll see examples later. -4. Listen to events for response. +4. Listen to `xhr` events for response. These three are the most widely used: - `load` -- when the result is ready, that includes HTTP errors like 404. @@ -110,7 +110,7 @@ xhr.onerror = function() { }; ``` -Once the server has responded, we can receive the result in the following properties of the request object: +Once the server has responded, we can receive the result in the following `xhr` properties: `status` : HTTP status code (a number): `200`, `404`, `403` and so on, can be `0` in case of a non-HTTP failure. @@ -119,7 +119,7 @@ Once the server has responded, we can receive the result in the following proper : HTTP status message (a string): usually `OK` for `200`, `Not Found` for `404`, `Forbidden` for `403` and so on. `response` (old scripts may use `responseText`) -: The server response. +: The server response body. We can also specify a timeout using the corresponding property: @@ -130,7 +130,7 @@ xhr.timeout = 10000; // timeout in ms, 10 seconds If the request does not succeed within the given time, it gets canceled and `timeout` event triggers. ````smart header="URL search parameters" -To pass URL parameters, like `?name=value`, and ensure the proper encoding, we can use [URL](info:url) object: +To add parameters to URL, like `?name=value`, and ensure the proper encoding, we can use [URL](info:url) object: ```js let url = new URL('https://google.com/search'); @@ -208,9 +208,7 @@ xhr.onreadystatechange = function() { }; ``` -You can find `readystatechange` listeners in really old code, it's there for historical reasons, as there was a time when there were no `load` and other events. - -Nowadays, `load/error/progress` handlers deprecate it. +You can find `readystatechange` listeners in really old code, it's there for historical reasons, as there was a time when there were no `load` and other events. Nowadays, `load/error/progress` handlers deprecate it. ## Aborting request @@ -305,7 +303,7 @@ There are 3 methods for HTTP-headers: Headers are returned as a single line, e.g.: - ``` + ```http Cache-Control: max-age=31536000 Content-Length: 4260 Content-Type: image/png @@ -327,6 +325,8 @@ There are 3 methods for HTTP-headers: result[name] = value; return result; }, {}); + + // headers['Content-Type'] = 'image/png' ``` ## POST, FormData @@ -340,14 +340,14 @@ let formData = new FormData([form]); // creates an object, optionally fill from formData.append(name, value); // appends a field ``` -We create it, optionally from a form, `append` more fields if needed, and then: +We create it, optionally fill from a form, `append` more fields if needed, and then: 1. `xhr.open('POST', ...)` – use `POST` method. 2. `xhr.send(formData)` to submit the form to the server. For instance: -```html run +```html run refresh