Skip to content

Commit 2a5c7e5

Browse files
committed
Merge branch 'master' of github.com:javascript-tutorial/en.javascript.info into sync-fb38a139
2 parents 381b69f + fb38a13 commit 2a5c7e5

114 files changed

Lines changed: 1322 additions & 1821 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* text=auto eol=lf
2+
*.svg binary

1-js/01-getting-started/2-manuals-specifications/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Also, if you're in developing for the browser, then there are other specs covere
2424
Although, it's often best to use an internet search instead. Just use "MDN [term]" in the query, e.g. <https://google.com/search?q=MDN+parseInt> to search for `parseInt` function.
2525

2626

27-
- **MSDN** – Microsoft manual with a lot of information, including JavaScript (often referrerd to as JScript). If one needs something specific to Internet Explorer, better go there: <http://msdn.microsoft.com/>.
27+
- **MSDN** – Microsoft manual with a lot of information, including JavaScript (often referred to as JScript). If one needs something specific to Internet Explorer, better go there: <http://msdn.microsoft.com/>.
2828

2929
Also, we can use an internet search with phrases such as "RegExp MSDN" or "RegExp MSDN jscript".
3030

1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ importance: 5
44

55
# Rewrite 'if' into '?'
66

7-
Rewrite this `if` using the ternary operator `'?'`:
7+
Rewrite this `if` using the conditional operator `'?'`:
88

99
```js
10+
let result;
11+
1012
if (a + b < 4) {
1113
result = 'Below';
1214
} else {
1315
result = 'Over';
1416
}
1517
```
16-

1-js/02-first-steps/13-switch/1-rewrite-switch-if-else/solution.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ For given strings though, a simple `'=='` works too.
44

55
```js no-beautify
66
if(browser == 'Edge') {
7-
alert("У вас браузер Edge!");
7+
alert("You've got the Edge!");
88
} else if (browser == 'Chrome'
99
|| browser == 'Firefox'
1010
|| browser == 'Safari'
1111
|| browser == 'Opera') {
12-
alert( 'Мы поддерживаем и эти браузерыo' );
12+
alert( 'Okay we support these browsers too' );
1313
} else {
14-
alert( 'Надеемся, что эта страница выглядит хорошо!' );
14+
alert( 'We hope that this page looks ok!' );
1515
}
1616
```
1717

1-js/02-first-steps/13-switch/1-rewrite-switch-if-else/task.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@ Write the code using `if..else` which would correspond to the following `switch`
99
```js
1010
switch (browser) {
1111
case 'Edge':
12-
alert( "У вас браузер Edge!" );
12+
alert( "You've got the Edge!" );
1313
break;
1414

1515
case 'Chrome':
1616
case 'Firefox':
1717
case 'Safari':
1818
case 'Opera':
19-
alert( 'Мы поддерживаем и эти браузеры' );
19+
alert( 'Okay we support these browsers too' );
2020
break;
2121

2222
default:
23-
alert( 'Надеемся, что эта страница выглядит хорошо!' );
23+
alert( 'We hope that this page looks ok!' );
2424
}
2525
```
26+

1-js/02-first-steps/14-function-basics/4-pow/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let x = prompt("x?", '');
1414
let n = prompt("n?", '');
1515

1616
if (n < 1) {
17-
alert(`Степень ${n} не поддерживается, только целая, большая 0`);
17+
alert(`Power ${n} is not supported, use a positive integer`);
1818
} else {
1919
alert( pow(x, n) );
2020
}

1-js/02-first-steps/14-function-basics/article.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,19 @@ That doesn't work, because JavaScript assumes a semicolon after `return`. That'l
338338
return*!*;*/!*
339339
(some + long + expression + or + whatever * f(a) + f(b))
340340
```
341-
So, it effectively becomes an empty return. We should put the value on the same line instead.
341+
342+
So, it effectively becomes an empty return.
343+
344+
If we want the returned expression to wrap across multiple lines, we should start it at the same line as `return`. Or at least put the opening parentheses there as follows:
345+
346+
```js
347+
return (
348+
some + long + expression
349+
+ or +
350+
whatever * f(a) + f(b)
351+
)
352+
```
353+
And it will work just as we expect it to.
342354
````
343355
344356
## Naming a function [#function-naming]

1-js/02-first-steps/15-function-expressions-arrows/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ let sayHi = function() {
9191
9292
The answer is simple:
9393
- There's no need for `;` at the end of code blocks and syntax structures that use them like `if { ... }`, `for { }`, `function f { }` etc.
94-
- A Function Expression is used inside the statement: `let sayHi = ...;`, as a value. It's not a code block, but rather an assignment. The semicolon `;` is recommended at the end of statements, no matter what is the value. So the semicolon here is not related to the Function Expression itself, it just terminates the statement.
94+
- A Function Expression is used inside the statement: `let sayHi = ...;`, as a value. It's not a code block, but rather an assignment. The semicolon `;` is recommended at the end of statements, no matter what the value is. So the semicolon here is not related to the Function Expression itself, it just terminates the statement.
9595
````
9696

9797
## Callback functions
@@ -133,7 +133,7 @@ ask("Do you agree?", showOk, showCancel);
133133

134134
Before we explore how we can write it in a much shorter way, let's note that in the browser (and on the server-side in some cases) such functions are quite popular. The major difference between a real-life implementation and the example above is that real-life functions use more complex ways to interact with the user than a simple `confirm`. In the browser, such a function usually draws a nice-looking question window. But that's another story.
135135

136-
**The arguments of `ask` are called *callback functions* or just *callbacks*.**
136+
**The arguments `showOk` and `showCancel` of `ask` are called *callback functions* or just *callbacks*.**
137137

138138
The idea is that we pass a function and expect it to be "called back" later if necessary. In our case, `showOk` becomes the callback for the "yes" answer, and `showCancel` for the "no" answer.
139139

1-js/04-object-basics/01-object/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ In that case the visitor may choose `__proto__` as the key, and the assignment l
236236
237237
There is a way to make objects treat `__proto__` as a regular property, which we'll cover later, but first we need to know more about objects.
238238
239-
There's also another data structure [Map](info:map-set-weakmap-weakset), that we'll learn in the chapter <info:map-set-weakmap-weakset>, which supports arbitrary keys.
239+
There's also another data structure [Map](info:map-set), that we'll learn in the chapter <info:map-set>, which supports arbitrary keys.
240240
````
241241

242242

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Here's the full list:
8686
|`\\`|Backslash|
8787
|`\t`|Tab|
8888
|`\b`, `\f`, `\v`| Backspace, Form Feed, Vertical Tab -- kept for compatibility, not used nowadays. |
89-
|`\xXX`|Unicode character with the given hexadimal unicode `XX`, e.g. `'\x7A'` is the same as `'z'`.|
89+
|`\xXX`|Unicode character with the given hexadecimal unicode `XX`, e.g. `'\x7A'` is the same as `'z'`.|
9090
|`\uXXXX`|A unicode symbol with the hex code `XXXX` in UTF-16 encoding, for instance `\u00A9` -- is a unicode for the copyright symbol `©`. It must be exactly 4 hex digits. |
9191
|`\u{X…XXXXXX}` (1 to 6 hex characters)|A unicode symbol with the given UTF-32 encoding. Some rare characters are encoded with two unicode symbols, taking 4 bytes. This way we can insert long codes. |
9292

0 commit comments

Comments
 (0)