Skip to content

Commit d816218

Browse files
authored
Merge branch 'master' into master
2 parents d0801c4 + a066108 commit d816218

File tree

37 files changed

+93
-71
lines changed

37 files changed

+93
-71
lines changed

1-js/01-getting-started/1-intro/article.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,4 @@ JavaScript-тің синтаксисі әркімнің қажеттілігін
120120
- JavaScript бастапқыда тек веб шолғышқа арналған тіл ретінде құрылды, бірақ қазір ол көптеген басқа орталарда қолданылады.
121121
- Бүгінгі таңда JavaScript HTML/CSS-те толық интеграцияланған веб шолғыштың ең кең таралған тілі ретінде бірегей орынға ие.
122122
- JavaScript-ке "аударылатын" және белгілі бір мүмкіндіктерді беретін көптеген тілдер бар. JavaScript-ті меңгергеннен кейін оларға қысқаша болса да қарауға ұсынылады.
123+

1-js/02-first-steps/01-hello-world/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Script files are attached to HTML with the `src` attribute:
7373
<script src="/path/to/script.js"></script>
7474
```
7575

76-
Here, `/path/to/script.js` is an absolute path to the script from the site root. One can also provide a relative path from the current page. For instance, `src="script.js"` would mean a file `"script.js"` in the current folder.
76+
Here, `/path/to/script.js` is an absolute path to the script from the site root. One can also provide a relative path from the current page. For instance, `src="script.js"`, just like `src="./script.js"`, would mean a file `"script.js"` in the current folder.
7777

7878
We can give a full URL as well. For instance:
7979

1-js/05-data-types/03-string/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Here's the full list:
8181
| Character | Description |
8282
|-----------|-------------|
8383
|`\n`|New line|
84-
|`\r`|Carriage return: not used alone. Windows text files use a combination of two characters `\r\n` to represent a line break. |
84+
|`\r`|In Windows text files a combination of two characters `\r\n` represents a new break, while on non-Windows OS it's just `\n`. That's for historical reasons, most Windows software also understands `\n`. |
8585
|`\'`, `\"`|Quotes|
8686
|`\\`|Backslash|
8787
|`\t`|Tab|

1-js/06-advanced-functions/03-closure/9-sort-by-field/_js.view/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe("byField", function(){
2323
{ name: "John", age: 20, surname: "Johnson"},
2424
];
2525
let ageSortedAnswer = users.sort(byField("age"));
26-
assert.deepEqual(ageSortedKey, ageSortedKey);
26+
assert.deepEqual(ageSortedKey, ageSortedAnswer);
2727
});
2828

2929
it("sorts users by surname", function(){

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ let user = {
187187

188188
let say = user.say.bind(user);
189189

190-
say("Hello"); // Hello, John ("Hello" argument is passed to say)
191-
say("Bye"); // Bye, John ("Bye" is passed to say)
190+
say("Hello"); // Hello, John! ("Hello" argument is passed to say)
191+
say("Bye"); // Bye, John! ("Bye" is passed to say)
192192
```
193193

194194
````smart header="Convenience method: `bindAll`"

1-js/09-classes/06-instanceof/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ The algorithm of `obj instanceof Class` works roughly as follows:
9393
alert(rabbit instanceof Animal); // true
9494
*/!*
9595
96-
// rabbit.__proto__ === Rabbit.prototype
96+
// rabbit.__proto__ === Animal.prototype (no match)
9797
*!*
9898
// rabbit.__proto__.__proto__ === Animal.prototype (match!)
9999
*/!*

1-js/11-async/02-promise-basics/03-animate-circle-promise/solution.view/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
text-align: center;
1111
}
1212
.circle {
13-
transition-property: width, height, margin-left, margin-top;
13+
transition-property: width, height;
1414
transition-duration: 2s;
1515
position: fixed;
1616
transform: translateX(-50%) translateY(-50%);

1-js/11-async/03-promise-chaining/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The idea is that the result is passed through the chain of `.then` handlers.
3737
Here the flow is:
3838
1. The initial promise resolves in 1 second `(*)`,
3939
2. Then the `.then` handler is called `(**)`, which in turn creates a new promise (resolved with `2` value).
40-
3. The next `then` `(***)` gets the result of the previous one, processes it (doubles) and passes the next handler.
40+
3. The next `then` `(***)` gets the result of the previous one, processes it (doubles) and passes it to the next handler.
4141
4. ...and so on.
4242

4343
As the result is passed along the chain of handlers, we can see a sequence of `alert` calls: `1` -> `2` -> `4`.

1-js/11-async/08-async-await/article.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,22 @@ showAvatar();
121121
122122
Pretty clean and easy to read, right? Much better than before.
123123
124-
````smart header="`await` won't work in the top-level code"
125-
People who are just starting to use `await` tend to forget the fact that we can't use `await` in top-level code. For example, this will not work:
124+
````smart header="Modern browsers allow top-level `await` in modules"
125+
In modern browsers, `await` on top level works just fine, when we're inside a module. We'll cover modules in article <info:modules-intro>.
126126
127-
```js run
128-
// syntax error in top-level code
127+
For instance:
128+
129+
```js run module
130+
// we assume this code runs at top level, inside a module
129131
let response = await fetch('/article/promise-chaining/user.json');
130132
let user = await response.json();
133+
134+
console.log(user);
131135
```
132136
133-
But we can wrap it into an anonymous async function, like this:
137+
If we're not using modules, or [older browsers](https://caniuse.com/mdn-javascript_operators_await_top_level) must be supported, there's a universal recipe: wrapping into an anonymous async function.
138+
139+
Lke this:
134140
135141
```js
136142
(async () => {
@@ -140,7 +146,6 @@ But we can wrap it into an anonymous async function, like this:
140146
})();
141147
```
142148
143-
P.S. New feature: starting from V8 engine version 8.9+, top-level await works in [modules](info:modules).
144149
````
145150

146151
````smart header="`await` accepts \"thenables\""
@@ -298,7 +303,7 @@ The `async` keyword before a function has two effects:
298303
299304
The `await` keyword before a promise makes JavaScript wait until that promise settles, and then:
300305
301-
1. If it's an error, the exception is generated — same as if `throw error` were called at that very place.
306+
1. If it's an error, an exception is generated — same as if `throw error` were called at that very place.
302307
2. Otherwise, it returns the result.
303308
304309
Together they provide a great framework to write asynchronous code that is easy to both read and write.

1-js/13-modules/01-modules-intro/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ Compare it to non-module scripts, where `this` is a global object:
261261
262262
There are also several browser-specific differences of scripts with `type="module"` compared to regular ones.
263263
264-
You may want skip this section for now if you're reading for the first time, or if you don't use JavaScript in a browser.
264+
You may want to skip this section for now if you're reading for the first time, or if you don't use JavaScript in a browser.
265265
266266
### Module scripts are deferred
267267

0 commit comments

Comments
 (0)