Skip to content

Commit 8365ea7

Browse files
committed
minor fixes
1 parent b1b66a3 commit 8365ea7

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

1-js/06-advanced-functions/04-var/article.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ alert(phrase); // Error, phrase is not defined
3131

3232
## "var" has no block scope
3333

34-
`var` variables are either function-wide or global, they are visible through blocks.
34+
Variables, declared with `var`, are either function-wide or global. They are visible through blocks.
3535

3636
For instance:
3737

@@ -45,7 +45,7 @@ alert(test); // true, the variable lives after if
4545
*/!*
4646
```
4747

48-
`var` ignores code blocks, so we've got a global variable `test`.
48+
As `var` ignores code blocks, we've got a global variable `test`.
4949

5050
If we used `let test` instead of `var test`, then the variable would only be visible inside `if`:
5151

1-js/06-advanced-functions/08-settimeout-setinterval/article.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ There are two methods for it:
99

1010
These methods are not a part of JavaScript specification. But most environments have the internal scheduler and provide these methods. In particular, they are supported in all browsers and Node.js.
1111

12-
1312
## setTimeout
1413

1514
The syntax:
@@ -291,9 +290,9 @@ For server-side JavaScript, that limitation does not exist, and there exist othe
291290
- To cancel the execution, we should call `clearInterval/clearTimeout` with the value returned by `setInterval/setTimeout`.
292291
- Nested `setTimeout` calls is a more flexible alternative to `setInterval`. Also they can guarantee the minimal time *between* the executions.
293292
- Zero delay scheduling with `setTimeout(func, 0)` (the same as `setTimeout(func)`) is used to schedule the call "as soon as possible, but after the current code is complete".
294-
- The browsere ensures that for five or more nested call of `setTimeout`, or for zero-delay `setInterval`, the real delay between calls is at least 4ms. That's for historical reasons.
293+
- The browser limits the minimal delay for five or more nested call of `setTimeout` or for `setInterval` (after 5th call) to 4ms. That's for historical reasons.
295294

296-
Please note that all scheduling methods do not *guarantee* the exact delay. We should not rely on that in the scheduled code.
295+
Please note that all scheduling methods do not *guarantee* the exact delay.
297296

298297
For example, the in-browser timer may slow down for a lot of reasons:
299298
- The CPU is overloaded.

1-js/07-object-properties/01-property-descriptors/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ user.name = "Pete"; // Error: Cannot assign to read only property 'name'...
122122

123123
Now no one can change the name of our user, unless they apply their own `defineProperty` to override ours.
124124

125-
```smart header="Errors appear only in use strict"
125+
```smart header="Errors appear only in strict mode"
126126
In the non-strict mode, no errors occur when writing to read-only properties and such. But the operation still won't succeed. Flag-violating actions are just silently ignored in non-strict.
127127
```
128128

1-js/11-async/05-promise-api/article.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Promise.all(requests)
112112
));
113113
```
114114

115-
A bigger example with fetching user information for an array of github users by their names (or we could fetch an array of goods by their ids, the logic is same):
115+
A bigger example with fetching user information for an array of GitHub users by their names (we could fetch an array of goods by their ids, the logic is same):
116116

117117
```js run
118118
let names = ['iliakan', 'remy', 'jeresig'];
@@ -134,7 +134,7 @@ Promise.all(requests)
134134
.then(users => users.forEach(user => alert(user.name)));
135135
```
136136

137-
**If any of the promises is rejected, `Promise.all` immediately rejects with that error.**
137+
**If any of the promises is rejected, the promise returned by `Promise.all` immediately rejects with that error.**
138138

139139
For instance:
140140

@@ -155,10 +155,10 @@ If one promise rejects, `Promise.all` immediately rejects, completely forgetting
155155
156156
For example, if there are multiple `fetch` calls, like in the example above, and one fails, other ones will still continue to execute, but `Promise.all` don't watch them any more. They will probably settle, but the result will be ignored.
157157
158-
`Promise.all` does nothing to cancel them, as there's no concept of "cancellation" in promises. In [another chapter](fetch-abort) we'll cover `AbortController` that aims to help with that, but it's not a part of the Promise API.
158+
`Promise.all` does nothing to cancel them, as there's no concept of "cancellation" in promises. In [another chapter](info:fetch-abort) we'll cover `AbortController` that can help with that, but it's not a part of the Promise API.
159159
```
160160

161-
````smart header="`Promise.all(...)` allows non-promise items in `iterable`"
161+
````smart header="`Promise.all(iterable)` allows non-promise \"regular\" values in `iterable`"
162162
Normally, `Promise.all(...)` accepts an iterable (in most cases an array) of promises. But if any of those objects is not a promise, it's wrapped in `Promise.resolve`.
163163

164164
For instance, here the results are `[1, 2, 3]`:
@@ -173,8 +173,7 @@ Promise.all([
173173
]).then(alert); // 1, 2, 3
174174
```
175175

176-
So we are able to pass non-promise values to `Promise.all` where convenient.
177-
176+
So we are able to pass ready values to `Promise.all` where convenient.
178177
````
179178
180179
## Promise.allSettled
@@ -289,4 +288,4 @@ There are 5 static methods of `Promise` class:
289288
- `value` (if fulfilled) or `reason` (if rejected).
290289
5. `Promise.race(promises)` -- waits for the first promise to settle, and its result/error becomes the outcome.
291290
292-
Of these five, `Promise.all/allSettled` are the most common in practice.
291+
Of these five, `Promise.all` is probably the most common in practice.

1-js/11-async/07-microtask-queue/article.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ That's strange, because the promise is definitely done from the beginning.
2121

2222
Why did the `.then` trigger afterwards? What's going on?
2323

24-
## Microtasks
24+
## Microtasks queue
2525

2626
Asynchronous tasks need proper management. For that, the standard specifies an internal queue `PromiseJobs`, more often referred to as "microtask queue" (v8 term).
2727

@@ -68,7 +68,7 @@ let promise = Promise.reject(new Error("Promise Failed!"));
6868
promise.catch(err => alert('caught'));
6969
*/!*
7070

71-
// no error, all quiet
71+
// doesn't run: error handled
7272
window.addEventListener('unhandledrejection', event => alert(event.reason));
7373
```
7474

@@ -93,13 +93,13 @@ setTimeout(() => promise.catch(err => alert('caught')), 1000);
9393
window.addEventListener('unhandledrejection', event => alert(event.reason));
9494
```
9595

96-
Now, if you run it, we'll see `Promise Failed!` message first, and then `caught`.
96+
Now, if you run it, we'll see `Promise Failed!` message first, and then `caught`.
9797

98-
If we didn't know about microtasks, we could wonder: "Why did `unhandledrejection` happen? We did catch the error!".
98+
If we didn't know about microtasks queue, we could wonder: "Why did `unhandledrejection` handler run? We did catch the error!".
9999

100-
But now we do know that `unhandledrejection` is generated when the microtask queue is complete: the engine examines promises and, if any of them is in "rejected" state, then the event triggers.
100+
But now we understand that `unhandledrejection` is generated when the microtask queue is complete: the engine examines promises and, if any of them is in "rejected" state, then the event triggers.
101101

102-
...By the way, the `.catch` added by `setTimeout` also triggers, of course it does, but later, after `unhandledrejection` has already occurred.
102+
In the example above, `.catch` added by `setTimeout` also triggers, but later, after `unhandledrejection` has already occurred, so that doesn't change anything.
103103

104104
## Summary
105105

2-ui/1-document/09-size-and-scroll/article.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ So, without scrollbar the content width would be `300px`, but if the scrollbar i
3939
```
4040

4141
```smart header="The `padding-bottom` area may be filled with text"
42-
Usually paddings are shown empty on illustrations, but if there's a lot of text in the element and it overflows, then browsers show the "overflowing" text at `padding-bottom`, so you can see that in examples. Still, the padding is set in further examples, unless explicitly specified otherwise.
42+
Usually paddings are shown empty on illustrations, but if there's a lot of text in the element and it overflows, then browsers show the "overflowing" text at `padding-bottom`.
43+
44+
That's a note to avoid confusion, as `padding-bottom` is set in further examples, unless explicitly specified otherwise.
4345
```
4446
4547
## Geometry
@@ -66,7 +68,7 @@ That's the nearest ancestor, that satisfies following conditions:
6668
2. or `<td>`, `<th>`, `<table>`,
6769
2. or `<body>`.
6870
69-
In most practical cases `offsetParent` is exactly the nearest ancestor, that is CSS-positioned. And `offsetLeft/offsetTop` provide x/y coordinates relative to its upper-left corner.
71+
Properties `offsetLeft/offsetTop` provide x/y coordinates relative to its upper-left corner.
7072
7173
In the example below the inner `<div>` has `<main>` as `offsetParent` and `offsetLeft/offsetTop` shifts from its upper-left corner (`180`):
7274
@@ -105,7 +107,7 @@ For our sample element:
105107
- `offsetWidth = 390` -- the outer width, can be calculated as inner CSS-width (`300px`) plus paddings (`2 * 20px`) and borders (`2 * 25px`).
106108
- `offsetHeight = 290` -- the outer height.
107109

108-
````smart header="Geometry properties for not displayed elements are zero/null"
110+
````smart header="Geometry properties are zero/null for elements that are not displayed"
109111
Geometry properties are calculated only for displayed elements.
110112
111113
If an element (or any of its ancestors) has `display:none` or is not in the document, then all geometry properties are zero (or `null` if that's `offsetParent`).

0 commit comments

Comments
 (0)