Skip to content

Commit 29ea890

Browse files
authored
Merge branch 'master' into patch-18
2 parents d0b95aa + c07eb5c commit 29ea890

File tree

17 files changed

+42
-43
lines changed

17 files changed

+42
-43
lines changed

1-js/04-object-basics/04-object-methods/3-why-this/task.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ importance: 3
44

55
# Explain the value of "this"
66

7-
In the code below we intend to call `user.go()` method 4 times in a row.
7+
In the code below we intend to call `obj.go()` method 4 times in a row.
88

99
But calls `(1)` and `(2)` works differently from `(3)` and `(4)`. Why?
1010

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ For server-side JavaScript, that limitation does not exist, and there exist othe
288288

289289
- Methods `setTimeout(func, delay, ...args)` and `setInterval(func, delay, ...args)` allow us to run the `func` once/regularly after `delay` milliseconds.
290290
- To cancel the execution, we should call `clearTimeout/clearInterval` with the value returned by `setTimeout/setInterval`.
291-
- Nested `setTimeout` calls is a more flexible alternative to `setInterval`, allowing us to set the time *between* executions more precisely.
291+
- Nested `setTimeout` calls are a more flexible alternative to `setInterval`, allowing us to set the time *between* executions more precisely.
292292
- 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 script is complete".
293293
- 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.
294294

@@ -299,4 +299,4 @@ For example, the in-browser timer may slow down for a lot of reasons:
299299
- The browser tab is in the background mode.
300300
- The laptop is on battery.
301301

302-
All that may increase the minimal timer resolution (the minimal delay) to 300ms or even 1000ms depending on the browser and OS-level performance settings.
302+
All that may increase the minimal timer resolution (the minimal delay) by 300ms or even 1000ms depending on the browser and OS-level performance settings.

1-js/06-advanced-functions/10-bind/6-ask-partial/task.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The task is a little more complex variant of <info:task/question-use-bind>.
88

99
The `user` object was modified. Now instead of two functions `loginOk/loginFail`, it has a single function `user.login(true/false)`.
1010

11-
What to pass `askPassword` in the code below, so that it calls `user.login(true)` as `ok` and `user.login(false)` as `fail`?
11+
What should we pass `askPassword` in the code below, so that it calls `user.login(true)` as `ok` and `user.login(false)` as `fail`?
1212

1313
```js
1414
function askPassword(ok, fail) {

1-js/06-advanced-functions/10-bind/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Functions provide a built-in method [bind](mdn:js/Function/bind) that allows to
9898
The basic syntax is:
9999

100100
```js
101-
// more complex syntax will be little later
101+
// more complex syntax will come a little later
102102
let boundFunc = func.bind(context);
103103
```
104104

1-js/06-advanced-functions/12-arrow-functions/article.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ Here we had to create additional variables `args` and `ctx` so that the function
118118

119119
Arrow functions:
120120

121-
- Do not have `this`.
122-
- Do not have `arguments`.
123-
- Can't be called with `new`.
124-
- (They also don't have `super`, but we didn't study it. Will be in the chapter <info:class-inheritance>).
121+
- Do not have `this`
122+
- Do not have `arguments`
123+
- Can't be called with `new`
124+
- They also don't have `super`, but we didn't study it yet. We will on the chapter <info:class-inheritance>
125125

126-
That's because they are meant for short pieces of code that do not have their own "context", but rather works in the current one. And they really shine in that use case.
126+
That's because they are meant for short pieces of code that do not have their own "context", but rather work in the current one. And they really shine in that use case.

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
As we know, objects can store properties.
55

6-
Till now, a property was a simple "key-value" pair to us. But an object property is actually a more flexible and powerful thing.
6+
Until now, a property was a simple "key-value" pair to us. But an object property is actually a more flexible and powerful thing.
77

88
In this chapter we'll study additional configuration options, and in the next we'll see how to invisibly turn them into getter/setter functions.
99

@@ -134,7 +134,7 @@ let user = { };
134134
Object.defineProperty(user, "name", {
135135
*!*
136136
value: "John",
137-
// for new properties need to explicitly list what's true
137+
// for new properties we need to explicitly list what's true
138138
enumerable: true,
139139
configurable: true
140140
*/!*
@@ -148,7 +148,7 @@ user.name = "Pete"; // Error
148148

149149
Now let's add a custom `toString` to `user`.
150150

151-
Normally, a built-in `toString` for objects is non-enumerable, it does not show up in `for..in`. But if we add `toString` of our own, then by default it shows up in `for..in`, like this:
151+
Normally, a built-in `toString` for objects is non-enumerable, it does not show up in `for..in`. But if we add a `toString` of our own, then by default it shows up in `for..in`, like this:
152152

153153
```js run
154154
let user = {
@@ -162,7 +162,7 @@ let user = {
162162
for (let key in user) alert(key); // name, toString
163163
```
164164

165-
If we don't like it, then we can set `enumerable:false`. Then it won't appear in `for..in` loop, just like the built-in one:
165+
If we don't like it, then we can set `enumerable:false`. Then it won't appear in a `for..in` loop, just like the built-in one:
166166

167167
```js run
168168
let user = {

1-js/07-object-properties/02-property-accessors/article.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
There are two kinds of properties.
55

6-
The first kind is *data properties*. We already know how to work with them. All properties that we've been using till now were data properties.
6+
The first kind is *data properties*. We already know how to work with them. All properties that we've been using until now were data properties.
77

88
The second type of properties is something new. It's *accessor properties*. They are essentially functions that work on getting and setting a value, but look like regular properties to an external code.
99

@@ -189,9 +189,9 @@ Technically, external code is able to access the name directly by using `user._n
189189

190190
## Using for compatibility
191191

192-
One of the great uses of accessors -- they allow to take control over a "regular" data property at any moment by replacing it with getter and setter and tweak its behavior.
192+
One of the great uses of accessors is that they allow to take control over a "regular" data property at any moment by replacing it with a getter and a setter and tweak its behavior.
193193

194-
Imagine, we started implementing user objects using data properties `name` and `age`:
194+
Imagine we started implementing user objects using data properties `name` and `age`:
195195

196196
```js
197197
function User(name, age) {

1-js/08-prototypes/01-prototype-inheritance/2-search-algorithm/task.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ importance: 5
66

77
The task has two parts.
88

9-
We have objects:
9+
Given the following objects:
1010

1111
```js
1212
let head = {

1-js/08-prototypes/01-prototype-inheritance/3-proto-and-this/task.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ importance: 5
22

33
---
44

5-
# Where it writes?
5+
# Where does it write?
66

77
We have `rabbit` inheriting from `animal`.
88

1-js/08-prototypes/01-prototype-inheritance/4-hamster-proto/task.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 5
22

33
---
44

5-
# Why two hamsters are full?
5+
# Why are both hamsters full?
66

77
We have two hamsters: `speedy` and `lazy` inheriting from the general `hamster` object.
88

9-
When we feed one of them, the other one is also full. Why? How to fix it?
9+
When we feed one of them, the other one is also full. Why? How can we fix it?
1010

1111
```js run
1212
let hamster = {

1-js/08-prototypes/01-prototype-inheritance/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ The resulting picture:
246246

247247
![](proto-animal-rabbit-walk-3.svg)
248248

249-
If we had other objects like `bird`, `snake` etc., inheriting from `animal`, they would also gain access to methods of `animal`. But `this` in each method call would be the corresponding object, evaluated at the call-time (before dot), not `animal`. So when we write data into `this`, it is stored into these objects.
249+
If we had other objects, like `bird`, `snake`, etc., inheriting from `animal`, they would also gain access to methods of `animal`. But `this` in each method call would be the corresponding object, evaluated at the call-time (before dot), not `animal`. So when we write data into `this`, it is stored into these objects.
250250

251251
As a result, methods are shared, but the object state is not.
252252

1-js/08-prototypes/02-function-prototype/1-changing-prototype/task.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ alert( rabbit.eats ); // true
2020
```
2121

2222

23-
1. We added one more string (emphasized), what `alert` shows now?
23+
1. We added one more string (emphasized). What will `alert` show now?
2424

2525
```js
2626
function Rabbit() {}
@@ -54,7 +54,7 @@ alert( rabbit.eats ); // true
5454
alert( rabbit.eats ); // ?
5555
```
5656

57-
3. Like this (replaced one line)?
57+
3. And like this (replaced one line)?
5858

5959
```js
6060
function Rabbit() {}

1-js/08-prototypes/02-function-prototype/article.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Remember, new objects can be created with a constructor function, like `new F()`.
44

5-
If `F.prototype` is an object, then `new` operator uses it to set `[[Prototype]]` for the new object.
5+
If `F.prototype` is an object, then the `new` operator uses it to set `[[Prototype]]` for the new object.
66

77
```smart
88
JavaScript had prototypal inheritance from the beginning. It was one of the core features of the language.
@@ -158,9 +158,9 @@ Rabbit.prototype = {
158158

159159
In this chapter we briefly described the way of setting a `[[Prototype]]` for objects created via a constructor function. Later we'll see more advanced programming patterns that rely on it.
160160

161-
Everything is quite simple, just few notes to make things clear:
161+
Everything is quite simple, just a few notes to make things clear:
162162

163-
- The `F.prototype` property (don't mess with `[[Prototype]]`) sets `[[Prototype]]` of new objects when `new F()` is called.
163+
- The `F.prototype` property (don't mistake it for `[[Prototype]]`) sets `[[Prototype]]` of new objects when `new F()` is called.
164164
- The value of `F.prototype` should be either an object or `null`: other values won't work.
165165
- The `"prototype"` property only has such a special effect when set on a constructor function, and invoked with `new`.
166166

1-js/99-js-misc/01-proxy/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ Here are examples of operations and `Reflect` calls that do the same:
603603
|-----------------|----------------|-------------|
604604
| `obj[prop]` | `Reflect.get(obj, prop)` | `[[Get]]` |
605605
| `obj[prop] = value` | `Reflect.set(obj, prop, value)` | `[[Set]]` |
606-
| `delete obj[prop]` | `Reflect.deleteProperty(obj, prop)` | `[[HasProperty]]` |
606+
| `delete obj[prop]` | `Reflect.deleteProperty(obj, prop)` | `[[Delete]]` |
607607
| `new F(value)` | `Reflect.construct(F, value)` | `[[Construct]]` |
608608
| ... | ... | ... |
609609

2-ui/1-document/07-modifying-document/article.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Modifying the document
22

3-
DOM modifications is the key to create "live" pages.
3+
DOM modification is the key to creating "live" pages.
44

55
Here we'll see how to create new elements "on the fly" and modify the existing page content.
66

77
## Example: show a message
88

9-
Let's see the methods on example. We'll add a message on the page that looks nicer than `alert`.
9+
Let's demonstrate using an example. We'll add a message on the page that looks nicer than `alert`.
1010

1111
Here's how it will look:
1212

@@ -93,9 +93,9 @@ Here's the full code:
9393
This set of methods provides more ways to insert:
9494

9595
- `node.append(...nodes or strings)` -- append nodes or strings at the end of `node`,
96-
- `node.prepend(...nodes or strings)` -- insert nodes or strings into the beginning of `node`,
97-
- `node.before(...nodes or strings)` –- insert nodes or strings before the `node`,
98-
- `node.after(...nodes or strings)` –- insert nodes or strings after the `node`,
96+
- `node.prepend(...nodes or strings)` -- insert nodes or strings at the beginning of `node`,
97+
- `node.before(...nodes or strings)` –- insert nodes or strings before `node`,
98+
- `node.after(...nodes or strings)` –- insert nodes or strings after `node`,
9999
- `node.replaceWith(...nodes or strings)` –- replaces `node` with the given nodes or strings.
100100

101101
Here's an example of using these methods to add items to a list and the text before/after it:
@@ -199,7 +199,7 @@ For instance:
199199
<p>Bye</p>
200200
```
201201

202-
That's how we can append an arbitrary HTML to the page.
202+
That's how we can append arbitrary HTML to the page.
203203

204204
Here's the picture of insertion variants:
205205

2-ui/5-loading/02-script-async-defer/article.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
In modern websites, scripts are often "heavier" than HTML: their download size is larger, and processing time is also longer.
55

6-
When the browser loads HTML and comes across a `<script>...</script>` tag, it can't continue building DOM. It must execute the script right now. The same happens for external scripts `<script src="..."></script>`: the browser must wait until the script downloads, execute it, and only after process the rest of the page.
6+
When the browser loads HTML and comes across a `<script>...</script>` tag, it can't continue building the DOM. It must execute the script right now. The same happens for external scripts `<script src="..."></script>`: the browser must wait until the script downloads, execute it, and only after process the rest of the page.
77

88
That leads to two important issues:
99

10-
1. Scripts can't see DOM elements below them, so can't add handlers etc.
10+
1. Scripts can't see DOM elements below them, so they can't add handlers etc.
1111
2. If there's a bulky script at the top of the page, it "blocks the page". Users can't see the page content till it downloads and runs:
1212

1313
```html run height=100
@@ -31,7 +31,7 @@ There are some workarounds to that. For instance, we can put a script at the bot
3131

3232
But this solution is far from perfect. For example, the browser notices the script (and can start downloading it) only after it downloaded the full HTML document. For long HTML documents, that may be a noticeable delay.
3333

34-
Such things are invisible for people using very fast connections, but many people in the world still have slower internet speeds and use far-from-perfect mobile internet.
34+
Such things are invisible for people using very fast connections, but many people in the world still have slow internet speeds and use a far-from-perfect mobile internet connection.
3535

3636
Luckily, there are two `<script>` attributes that solve the problem for us: `defer` and `async`.
3737

@@ -68,7 +68,7 @@ The following example demonstrates that:
6868
```
6969

7070
1. The page content shows up immediately.
71-
2. `DOMContentLoaded` waits for the deferred script. It only triggers when the script `(2)` is downloaded is executed.
71+
2. `DOMContentLoaded` waits for the deferred script. It only triggers when the script `(2)` is downloaded and executed.
7272

7373
Deferred scripts keep their relative order, just like regular scripts.
7474

@@ -94,8 +94,8 @@ The `defer` attribute is ignored if the `<script>` tag has no `src`.
9494
9595
The `async` attribute means that a script is completely independent:
9696
97-
- The page doesn't wait for async scripts, the contents is processed and displayed.
98-
- `DOMContentLoaded` and async scripts don't wait each other:
97+
- The page doesn't wait for async scripts, the contents are processed and displayed.
98+
- `DOMContentLoaded` and async scripts don't wait for each other:
9999
- `DOMContentLoaded` may happen both before an async script (if an async script finishes loading after the page is complete)
100100
- ...or after an async script (if an async script is short or was in HTTP-cache)
101101
- Other scripts don't wait for `async` scripts, and `async` scripts don't wait for them.
@@ -146,7 +146,6 @@ That is:
146146
- They don't wait for anything, nothing waits for them.
147147
- The script that loads first -- runs first ("load-first" order).
148148

149-
We can change the load-first order into the document order (just like regular scripts) by explicitly setting `async` property to `false`:
150149

151150
```js run
152151
let script = document.createElement('script');
@@ -192,7 +191,7 @@ Please note that if you're using `defer`, then the page is visible *before* the
192191
193192
So the user may read the page, but some graphical components are probably not ready yet.
194193
195-
There should be "loading" indication in proper places, not-working buttons disabled, to clearly show the user what's ready and what's not.
194+
There should be "loading" indications in the proper places, and disabled buttons should show as such, so the user can clearly see what's ready and what's not.
196195
```
197196

198197
In practice, `defer` is used for scripts that need the whole DOM and/or their relative execution order is important. And `async` is used for independent scripts, like counters or ads. And their relative execution order does not matter.

9-regular-expressions/10-regexp-greedy-and-lazy/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ To clearly understand the change, let's trace the search step by step.
140140

141141
![](witch_lazy6.svg)
142142

143-
In this example we saw how the lazy mode works for `pattern:+?`. Quantifiers `pattern:+?` and `pattern:??` work the similar way -- the regexp engine increases the number of repetitions only if the rest of the pattern can't match on the given position.
143+
In this example we saw how the lazy mode works for `pattern:+?`. Quantifiers `pattern:*?` and `pattern:??` work the similar way -- the regexp engine increases the number of repetitions only if the rest of the pattern can't match on the given position.
144144

145145
**Laziness is only enabled for the quantifier with `?`.**
146146

0 commit comments

Comments
 (0)