Skip to content

Commit 4690b7e

Browse files
committed
Merge branch 'master' of github.com:javascript-tutorial/en.javascript.info into sync-7b761858
2 parents 15a0c13 + 7b76185 commit 4690b7e

File tree

20 files changed

+157
-79
lines changed

20 files changed

+157
-79
lines changed

1-js/02-first-steps/08-operators/article.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,21 @@ alert( 8 % 3 ); // 2, a remainder of 8 divided by 3
5656

5757
### Exponentiation **
5858

59-
The exponentiation operator `a ** b` multiplies `a` by itself `b` times.
59+
The exponentiation operator `a ** b` raises `a` to the power of `b`.
60+
61+
In school maths, we write that as a<sup>b</sup>.
6062

6163
For instance:
6264

6365
```js run
64-
alert( 2 ** 2 ); // 4 (2 multiplied by itself 2 times)
65-
alert( 2 ** 3 ); // 8 (2 * 2 * 2, 3 times)
66-
alert( 2 ** 4 ); // 16 (2 * 2 * 2 * 2, 4 times)
66+
alert( 2 ** 2 ); // 2² = 4
67+
alert( 2 ** 3 ); // 2³ = 8
68+
alert( 2 ** 4 ); // 2⁴ = 16
6769
```
6870

69-
Mathematically, the exponentiation is defined for non-integer numbers as well. For example, a square root is an exponentiation by `1/2`:
71+
Just like in maths, the exponentiation operator is defined for non-integer numbers as well.
72+
73+
For example, a square root is an exponentiation by ½:
7074

7175
```js run
7276
alert( 4 ** (1/2) ); // 2 (power of 1/2 is the same as a square root)

1-js/02-first-steps/13-while-for/article.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,18 @@ break label; // jump to the label below (doesn't work)
368368
label: for (...)
369369
```
370370
371-
A call to `continue` is only possible from inside the loop.
371+
A `break` directive must be inside a code block. Technically, any labelled code block will do, e.g.:
372+
```js
373+
label: {
374+
// ...
375+
break label; // works
376+
// ...
377+
}
378+
```
379+
380+
...Although, 99.9% of the time `break` used is inside loops, as we've seen in the examples above.
372381
373-
The `break` directive may be placed before code blocks too, as `label: { ... }`, but it's almost never used like that. And it also works only inside-out.
382+
A `continue` is only possible from inside a loop.
374383
````
375384

376385
## Summary

1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ function checkAge(age) {
1414
}
1515
```
1616

17-
Note that the parentheses around `age > 18` are not required here. They exist for better readabilty.
17+
Note that the parentheses around `age > 18` are not required here. They exist for better readability.

1-js/02-first-steps/17-arrow-functions-basics/1-rewrite-arrow/solution.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
```js run
33
function ask(question, yes, no) {
4-
if (confirm(question)) yes()
4+
if (confirm(question)) yes();
55
else no();
66
}
77

1-js/02-first-steps/17-arrow-functions-basics/1-rewrite-arrow/task.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Replace Function Expressions with arrow functions in the code below:
55

66
```js run
77
function ask(question, yes, no) {
8-
if (confirm(question)) yes()
8+
if (confirm(question)) yes();
99
else no();
1010
}
1111

1-js/05-data-types/08-weakmap-weakset/01-recipients-read/solution.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ messages.shift();
2525
// now readMessages has 1 element (technically memory may be cleaned later)
2626
```
2727

28-
The `WeakSet` allows to store a set of messages and easily check for the existance of a message in it.
28+
The `WeakSet` allows to store a set of messages and easily check for the existence of a message in it.
2929

3030
It cleans up itself automatically. The tradeoff is that we can't iterate over it, can't get "all read messages" from it directly. But we can do it by iterating over all messages and filtering those that are in the set.
3131

1-js/05-data-types/11-date/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ let time1 = 0;
348348
let time2 = 0;
349349

350350
*!*
351-
// run bench(upperSlice) and bench(upperLoop) each 10 times alternating
351+
// run bench(diffSubtract) and bench(diffGetTime) each 10 times alternating
352352
for (let i = 0; i < 10; i++) {
353353
time1 += bench(diffSubtract);
354354
time2 += bench(diffGetTime);

1-js/06-advanced-functions/03-closure/10-make-army/solution.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ Let's examine what exactly happens inside `makeArmy`, and the solution will beco
8888
8989
Here `let j = i` declares an "iteration-local" variable `j` and copies `i` into it. Primitives are copied "by value", so we actually get an independent copy of `i`, belonging to the current loop iteration.
9090
91-
The shooters work correctly, because the value of `i` now lives a little bit closer. Not in `makeArmy()` Lexical Environment, but in the Lexical Environment that corresponds the current loop iteration:
91+
The shooters work correctly, because the value of `i` now lives a little bit closer. Not in `makeArmy()` Lexical Environment, but in the Lexical Environment that corresponds to the current loop iteration:
9292
9393
![](lexenv-makearmy-while-fixed.svg)
9494
95-
Such problem could also be avoided if we used `for` in the beginning, like this:
95+
Such a problem could also be avoided if we used `for` in the beginning, like this:
9696
9797
```js run demo
9898
function makeArmy() {

1-js/06-advanced-functions/03-closure/7-let-scope/solution.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The code above demonstrates it.
2727
function func() {
2828
*!*
2929
// the local variable x is known to the engine from the beginning of the function,
30-
// but "unitialized" (unusable) until let ("dead zone")
30+
// but "uninitialized" (unusable) until let ("dead zone")
3131
// hence the error
3232
*/!*
3333

1-js/06-advanced-functions/03-closure/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Despite being simple, slightly modified variants of that code have practical use
146146

147147
How does this work? If we create multiple counters, will they be independent? What's going on with the variables here?
148148

149-
Undestanding such things is great for the overall knowledge of JavaScript and beneficial for more complex scenarios. So let's go a bit in-depth.
149+
Understanding such things is great for the overall knowledge of JavaScript and beneficial for more complex scenarios. So let's go a bit in-depth.
150150

151151
## Lexical Environment
152152

1-js/06-advanced-functions/06-function-object/5-sum-many-brackets/solution.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ function f(b) {
5252
}
5353
```
5454

55-
This `f` will be used in the next call, again return itself, so many times as needed. Then, when used as a number or a string -- the `toString` returns the `currentSum`. We could also use `Symbol.toPrimitive` or `valueOf` here for the conversion.
55+
This `f` will be used in the next call, again return itself, as many times as needed. Then, when used as a number or a string -- the `toString` returns the `currentSum`. We could also use `Symbol.toPrimitive` or `valueOf` here for the conversion.

1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ function throttle(func, ms) {
1212
savedThis = this;
1313
return;
1414
}
15+
isThrottled = true;
1516

1617
func.apply(this, arguments); // (1)
1718

18-
isThrottled = true;
19-
2019
setTimeout(function() {
2120
isThrottled = false; // (3)
2221
if (savedArgs) {

1-js/09-classes/01-class/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ alert(typeof User); // function
110110
alert(User === User.prototype.constructor); // true
111111

112112
// The methods are in User.prototype, e.g:
113-
alert(User.prototype.sayHi); // alert(this.name);
113+
alert(User.prototype.sayHi); // the code of the sayHi method
114114

115115
// there are exactly two methods in the prototype
116116
alert(Object.getOwnPropertyNames(User.prototype)); // constructor, sayHi

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ The function execution "pauses" at the line `(*)` and resumes when the promise s
6969

7070
Let's emphasize: `await` literally suspends the function execution until the promise settles, and then resumes it with the promise result. That doesn't cost any CPU resources, because the JavaScript engine can do other jobs in the meantime: execute other scripts, handle events, etc.
7171

72-
It's just a more elegant syntax of getting the promise result than `promise.then`, easier to read and write.
72+
It's just a more elegant syntax of getting the promise result than `promise.then`. And, it's easier to read and write.
7373

7474
````warn header="Can't use `await` in regular functions"
75-
If we try to use `await` in non-async function, there would be a syntax error:
75+
If we try to use `await` in a non-async function, there would be a syntax error:
7676

7777
```js run
7878
function f() {
@@ -83,7 +83,7 @@ function f() {
8383
}
8484
```
8585

86-
We may get this error if we forget to put `async` before a function. As said, `await` only works inside an `async` function.
86+
We may get this error if we forget to put `async` before a function. As stated earlier, `await` only works inside an `async` function.
8787
````
8888
8989
Let's take the `showAvatar()` example from the chapter <info:promise-chaining> and rewrite it using `async/await`:
@@ -186,7 +186,7 @@ class Waiter {
186186
187187
new Waiter()
188188
.wait()
189-
.then(alert); // 1
189+
.then(alert); // 1 (this is the same as (result => alert(result)))
190190
```
191191
The meaning is the same: it ensures that the returned value is a promise and enables `await`.
192192
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
The HTML in the task is incorrect. That's the reason of the odd thing.
22

3-
The browser has to fix it automatically. But there may be no text inside the `<table>`: according to the spec only table-specific tags are allowed. So the browser adds `"aaa"` *before* the `<table>`.
3+
The browser has to fix it automatically. But there may be no text inside the `<table>`: according to the spec only table-specific tags are allowed. So the browser shows `"aaa"` *before* the `<table>`.
44

55
Now it's obvious that when we remove the table, it remains.
66

7-
The question can be easily answered by exploring the DOM using the browser tools. It shows `"aaa"` before the `<table>`.
7+
The question can be easily answered by exploring the DOM using the browser tools. You'll see `"aaa"` before the `<table>`.
88

99
The HTML standard specifies in detail how to process bad HTML, and such behavior of the browser is correct.

2-ui/3-event-details/4-mouse-drag-and-drop/article.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Let's update our algorithm:
124124

125125
```js
126126
// onmousemove
127-
// ball has position:absoute
127+
// ball has position:absolute
128128
ball.style.left = event.pageX - *!*shiftX*/!* + 'px';
129129
ball.style.top = event.pageY - *!*shiftY*/!* + 'px';
130130
```

0 commit comments

Comments
 (0)