You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/06-advanced-functions/08-settimeout-setinterval/article.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -288,7 +288,7 @@ For server-side JavaScript, that limitation does not exist, and there exist othe
288
288
289
289
- Methods `setTimeout(func, delay, ...args)` and `setInterval(func, delay, ...args)` allow us to run the `func` once/regularly after `delay` milliseconds.
290
290
- 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.
292
292
- 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".
293
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.
294
294
@@ -299,4 +299,4 @@ For example, the in-browser timer may slow down for a lot of reasons:
299
299
- The browser tab is in the background mode.
300
300
- The laptop is on battery.
301
301
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.
Copy file name to clipboardExpand all lines: 1-js/06-advanced-functions/12-arrow-functions/article.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -118,9 +118,9 @@ Here we had to create additional variables `args` and `ctx` so that the function
118
118
119
119
Arrow functions:
120
120
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>
125
125
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.
Copy file name to clipboardExpand all lines: 1-js/07-object-properties/01-property-descriptors/article.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
4
4
As we know, objects can store properties.
5
5
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.
7
7
8
8
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.
9
9
@@ -134,7 +134,7 @@ let user = { };
134
134
Object.defineProperty(user, "name", {
135
135
*!*
136
136
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
138
138
enumerable:true,
139
139
configurable:true
140
140
*/!*
@@ -148,7 +148,7 @@ user.name = "Pete"; // Error
148
148
149
149
Now let's add a custom `toString` to `user`.
150
150
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:
152
152
153
153
```js run
154
154
let user = {
@@ -162,7 +162,7 @@ let user = {
162
162
for (let key in user) alert(key); // name, toString
163
163
```
164
164
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:
Copy file name to clipboardExpand all lines: 1-js/07-object-properties/02-property-accessors/article.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
4
4
There are two kinds of properties.
5
5
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.
7
7
8
8
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.
9
9
@@ -189,9 +189,9 @@ Technically, external code is able to access the name directly by using `user._n
189
189
190
190
## Using for compatibility
191
191
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.
193
193
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`:
Copy file name to clipboardExpand all lines: 1-js/08-prototypes/01-prototype-inheritance/article.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -246,7 +246,7 @@ The resulting picture:
246
246
247
247

248
248
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.
250
250
251
251
As a result, methods are shared, but the object state is not.
Copy file name to clipboardExpand all lines: 1-js/08-prototypes/02-function-prototype/article.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
Remember, new objects can be created with a constructor function, like `new F()`.
4
4
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.
6
6
7
7
```smart
8
8
JavaScript had prototypal inheritance from the beginning. It was one of the core features of the language.
@@ -158,9 +158,9 @@ Rabbit.prototype = {
158
158
159
159
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.
160
160
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:
162
162
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.
164
164
- The value of `F.prototype` should be either an object or `null`: other values won'twork.
165
165
-The`"prototype"`propertyonlyhassuchaspecialeffectwhensetonaconstructor function, and invoked with `new`.
Copy file name to clipboardExpand all lines: 2-ui/5-loading/02-script-async-defer/article.md
+7-8
Original file line number
Diff line number
Diff line change
@@ -3,11 +3,11 @@
3
3
4
4
In modern websites, scripts are often "heavier" than HTML: their download size is larger, and processing time is also longer.
5
5
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.
7
7
8
8
That leads to two important issues:
9
9
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.
11
11
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:
12
12
13
13
```html run height=100
@@ -31,7 +31,7 @@ There are some workarounds to that. For instance, we can put a script at the bot
31
31
32
32
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.
33
33
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.
35
35
36
36
Luckily, there are two `<script>` attributes that solve the problem for us: `defer` and `async`.
37
37
@@ -68,7 +68,7 @@ The following example demonstrates that:
68
68
```
69
69
70
70
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.
72
72
73
73
Deferred scripts keep their relative order, just like regular scripts.
74
74
@@ -94,8 +94,8 @@ The `defer` attribute is ignored if the `<script>` tag has no `src`.
94
94
95
95
The `async` attribute means that a script is completely independent:
96
96
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:
99
99
- `DOMContentLoaded` may happen both before an async script (if an async script finishes loading after the page is complete)
100
100
- ...or after an async script (if an async script is short or was in HTTP-cache)
101
101
- Other scripts don't wait for `async` scripts, and `async` scripts don't wait for them.
@@ -146,7 +146,6 @@ That is:
146
146
- They don't wait for anything, nothing waits for them.
147
147
- The script that loads first -- runs first ("load-first" order).
148
148
149
-
We can change the load-first order into the document order (just like regular scripts) by explicitly setting `async` property to `false`:
150
149
151
150
```js run
152
151
let script =document.createElement('script');
@@ -192,7 +191,7 @@ Please note that if you're using `defer`, then the page is visible *before* the
192
191
193
192
So the user may read the page, but some graphical components are probably not ready yet.
194
193
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.
196
195
```
197
196
198
197
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.
Copy file name to clipboardExpand all lines: 9-regular-expressions/10-regexp-greedy-and-lazy/article.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -140,7 +140,7 @@ To clearly understand the change, let's trace the search step by step.
140
140
141
141

142
142
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.
144
144
145
145
**Laziness is only enabled for the quantifier with `?`.**
0 commit comments