Skip to content

Commit 81e06e5

Browse files
committed
Merge branch 'master' of github.com:javascript-tutorial/en.javascript.info into sync-c4d1987e
2 parents 65e9233 + c4d1987 commit 81e06e5

File tree

31 files changed

+75
-70
lines changed

31 files changed

+75
-70
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This book is a *tutorial*. It aims to help you gradually learn the language. But
55

66
## Specification
77

8-
**The ECMA-262 specification** contains the most in-depth, detailed and formalized information about JavaScript. It defines the language.
8+
[The ECMA-262 specification](https://www.ecma-international.org/publications/standards/Ecma-262.htm) contains the most in-depth, detailed and formalized information about JavaScript. It defines the language.
99

1010
But being that formalized, it's difficult to understand at first. So if you need the most trustworthy source of information about the language details, the specification is the right place. But it's not for everyday use.
1111

1-js/02-first-steps/04-variables/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A [variable](https://en.wikipedia.org/wiki/Variable_(computer_science)) is a "na
1212

1313
To create a variable in JavaScript, use the `let` keyword.
1414

15-
The statement below creates (in other words: *declares* or *defines*) a variable with the name "message":
15+
The statement below creates (in other words: *declares*) a variable with the name "message":
1616

1717
```js
1818
let message;

1-js/02-first-steps/06-type-conversions/1-primitive-conversions-questions/solution.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ true + false = 1
1414
" -9 " - 5 = -14 // (4)
1515
null + 1 = 1 // (5)
1616
undefined + 1 = NaN // (6)
17+
" \t \n" - 2 = -2 // (7)
1718
```
1819

1920
1. The addition with a string `"" + 1` converts `1` to a string: `"" + 1 = "1"`, and then we have `"1" + 0`, the same rule is applied.
@@ -22,3 +23,4 @@ undefined + 1 = NaN // (6)
2223
4. The subtraction always converts to numbers, so it makes `" -9 "` a number `-9` (ignoring spaces around it).
2324
5. `null` becomes `0` after the numeric conversion.
2425
6. `undefined` becomes `NaN` after the numeric conversion.
26+
7. Space characters, are trimmed off string start and end when a string is converted to a number. Here the whole string consists of space characters, such as `\t`, `\n` and a "regular" space between them. So, similarly to an empty string, it becomes `0`.

1-js/02-first-steps/06-type-conversions/1-primitive-conversions-questions/task.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ true + false
2121
" -9 " - 5
2222
null + 1
2323
undefined + 1
24+
" \t \n" - 2
2425
```
2526

2627
Think well, write down and then compare with the answer.

1-js/02-first-steps/06-type-conversions/article.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ There are also cases when we need to explicitly convert a value to the expected
1010
In this chapter, we won't cover objects. Instead, we'll study primitives first. Later, after we learn about objects, we'll see how object conversion works in the chapter <info:object-toprimitive>.
1111
```
1212

13-
## ToString
13+
## To String
1414

1515
String conversion happens when we need the string form of a value.
1616

@@ -30,7 +30,7 @@ alert(typeof value); // string
3030

3131
String conversion is mostly obvious. A `false` becomes `"false"`, `null` becomes `"null"`, etc.
3232

33-
## ToNumber
33+
## To Number
3434

3535
Numeric conversion happens in mathematical functions and expressions automatically.
3636

@@ -94,7 +94,7 @@ alert( '1' + 2 ); // '12' (string to the left)
9494
This only happens when at least one of the arguments is a string. Otherwise, values are converted to numbers.
9595
````
9696

97-
## ToBoolean
97+
## To Boolean
9898

9999
Boolean conversion is the simplest one.
100100

@@ -129,9 +129,9 @@ alert( Boolean(" ") ); // spaces, also true (any non-empty string is true)
129129
130130
The three most widely used type conversions are to string, to number, and to boolean.
131131
132-
**`ToString`** -- Occurs when we output something. Can be performed with `String(value)`. The conversion to string is usually obvious for primitive values.
132+
**`To String`** -- Occurs when we output something. Can be performed with `String(value)`. The conversion to string is usually obvious for primitive values.
133133
134-
**`ToNumber`** -- Occurs in math operations. Can be performed with `Number(value)`.
134+
**`To Number`** -- Occurs in math operations. Can be performed with `Number(value)`.
135135
136136
The conversion follows the rules:
137137
@@ -142,7 +142,7 @@ The conversion follows the rules:
142142
|<code>true&nbsp;/&nbsp;false</code> | `1 / 0` |
143143
| `string` | The string is read "as is", whitespaces from both sides are ignored. An empty string becomes `0`. An error gives `NaN`. |
144144
145-
**`ToBoolean`** -- Occurs in logical operations. Can be performed with `Boolean(value)`.
145+
**`To Boolean`** -- Occurs in logical operations. Can be performed with `Boolean(value)`.
146146
147147
Follows the rules:
148148

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Before we move on, let's grasp some common terminology.
2626
alert( y - x ); // 2, binary minus subtracts values
2727
```
2828

29-
Formally, we're talking about two different operators here: the unary negation (single operand: reverses the sign) and the binary subtraction (two operands: subtracts).
29+
Formally, in the examples above we have two different operators that share the same symbol: the negation operator, a unary operator that reverses the sign, and the subtraction operator, a binary operator that subtracts one number from another.
3030

3131
## String concatenation, binary +
3232

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ Let's examine the `for` statement part-by-part:
108108
|-------|----------|----------------------------------------------------------------------------|
109109
| begin | `i = 0` | Executes once upon entering the loop. |
110110
| condition | `i < 3`| Checked before every loop iteration. If false, the loop stops. |
111-
| step| `i++` | Executes after the body on each iteration but before the condition check. |
112111
| body | `alert(i)`| Runs again and again while the condition is truthy. |
112+
| step| `i++` | Executes after the body on each iteration. |
113113

114114
The general loop algorithm works like this:
115115

@@ -300,7 +300,7 @@ This is just another reason not to use the question mark operator `?` instead of
300300

301301
Sometimes we need to break out from multiple nested loops at once.
302302

303-
For example, in the code below we loop over `i` and `j`, prompting for the coordinates `(i, j)` from `(0,0)` to `(3,3)`:
303+
For example, in the code below we loop over `i` and `j`, prompting for the coordinates `(i, j)` from `(0,0)` to `(2,2)`:
304304

305305
```js run no-beautify
306306
for (let i = 0; i < 3; i++) {

1-js/02-first-steps/16-javascript-specials/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Conditional
149149
: The only operator with three parameters: `cond ? resultA : resultB`. If `cond` is truthy, returns `resultA`, otherwise `resultB`.
150150

151151
Logical operators
152-
: Logical AND `&&` and OR `||` perform short-circuit evaluation and then return the value where it stopped. Logical NOT `!` converts the operand to boolean type and returns the inverse value.
152+
: Logical AND `&&` and OR `||` perform short-circuit evaluation and then return the value where it stopped (not necessary `true`/`false`). Logical NOT `!` converts the operand to boolean type and returns the inverse value.
153153

154154
Comparisons
155155
: Equality check `==` for values of different types converts them to a number (except `null` and `undefined` that equal each other and nothing else), so these are equal:

1-js/03-code-quality/03-comments/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,6 @@ Good comments allow us to maintain the code well, come back to it after a delay
175175
**Avoid comments:**
176176

177177
- That tell "how code works" and "what it does".
178-
- Put them only if it's impossible to make the code so simple and self-descriptive that it doesn't require those.
178+
- Put them in only if it's impossible to make the code so simple and self-descriptive that it doesn't require them.
179179

180180
Comments are also used for auto-documenting tools like JSDoc3: they read them and generate HTML-docs (or docs in another format).

1-js/03-code-quality/06-polyfills/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Here Babel comes to the rescue.
1919

2020
Actually, there are two parts in Babel:
2121

22-
1. First, the transpiler program, which rewrites the code. The developer runs it on their own computer. It rewrites the code into the older standard. And then the code is delivered to the website for users. Modern project build system like [webpack](http://webpack.github.io/) provide means to run transpiler automatically on every code change, so that very easy to integrate into development process.
22+
1. First, the transpiler program, which rewrites the code. The developer runs it on their own computer. It rewrites the code into the older standard. And then the code is delivered to the website for users. Modern project build systems like [webpack](http://webpack.github.io/) provide means to run transpiler automatically on every code change, so that very easy to integrate into development process.
2323

2424
2. Second, the polyfill.
2525

0 commit comments

Comments
 (0)