Skip to content

Commit baa95a7

Browse files
committed
Update basic operators
1 parent af29030 commit baa95a7

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

1-js/02-first-steps/08-operators/3-primitive-conversions-questions/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ undefined + 1 = NaN // (6)
2222
4. The subtraction always converts to numbers, so it makes `" -9 "` a number `-9` (ignoring spaces around it).
2323
5. `null` becomes `0` after the numeric conversion.
2424
6. `undefined` becomes `NaN` after the numeric conversion.
25-
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`.
25+
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/08-operators/article.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ The result of `a % b` is the [remainder](https://en.wikipedia.org/wiki/Remainder
5050
For instance:
5151

5252
```js run
53-
alert( 5 % 2 ); // 1, a remainder of 5 divided by 2
54-
alert( 8 % 3 ); // 2, a remainder of 8 divided by 3
53+
alert( 5 % 2 ); // 1, the remainder of 5 divided by 2
54+
alert( 8 % 3 ); // 2, the remainder of 8 divided by 3
55+
alert( 8 % 4 ); // 0, the remainder of 8 divided by 4
5556
```
5657

5758
### Exponentiation **
@@ -68,7 +69,7 @@ alert( 2 ** 3 ); // 2³ = 8
6869
alert( 2 ** 4 ); // 2⁴ = 16
6970
```
7071

71-
Just like in maths, the exponentiation operator is defined for non-integer numbers as well.
72+
Just like in maths, the exponentiation operator is defined for non-integer numbers as well.
7273

7374
For example, a square root is an exponentiation by ½:
7475

@@ -80,7 +81,7 @@ alert( 8 ** (1/3) ); // 2 (power of 1/3 is the same as a cubic root)
8081

8182
## String concatenation with binary +
8283

83-
Let's meet features of JavaScript operators that are beyond school arithmetics.
84+
Let's meet the features of JavaScript operators that are beyond school arithmetics.
8485
8586
Usually, the plus operator `+` sums numbers.
8687
@@ -194,18 +195,18 @@ Here's an extract from the [precedence table](https://developer.mozilla.org/en-U
194195
| Precedence | Name | Sign |
195196
|------------|------|------|
196197
| ... | ... | ... |
197-
| 15 | unary plus | `+` |
198-
| 15 | unary negation | `-` |
199-
| 14 | exponentiation | `**` |
200-
| 13 | multiplication | `*` |
201-
| 13 | division | `/` |
202-
| 12 | addition | `+` |
203-
| 12 | subtraction | `-` |
198+
| 14 | unary plus | `+` |
199+
| 14 | unary negation | `-` |
200+
| 13 | exponentiation | `**` |
201+
| 12 | multiplication | `*` |
202+
| 12 | division | `/` |
203+
| 11 | addition | `+` |
204+
| 11 | subtraction | `-` |
204205
| ... | ... | ... |
205206
| 2 | assignment | `=` |
206207
| ... | ... | ... |
207208

208-
As we can see, the "unary plus" has a priority of `15` which is higher than the `12` of "addition" (binary plus). That's why, in the expression `"+apples + +oranges"`, unary pluses work before the addition.
209+
As we can see, the "unary plus" has a priority of `14` which is higher than the `11` of "addition" (binary plus). That's why, in the expression `"+apples + +oranges"`, unary pluses work before the addition.
209210
210211
## Assignment
211212
@@ -303,9 +304,9 @@ Such operators have the same precedence as a normal assignment, so they run afte
303304
```js run
304305
let n = 2;
305306
306-
n *= 3 + 5;
307+
n *= 3 + 5; // right part evaluated first, same as n *= 8
307308
308-
alert( n ); // 16 (right part evaluated first, same as n *= 8)
309+
alert( n ); // 16
309310
```
310311

311312
## Increment/decrement
@@ -437,7 +438,7 @@ The list of operators:
437438
- RIGHT SHIFT ( `>>` )
438439
- ZERO-FILL RIGHT SHIFT ( `>>>` )
439440
440-
These operators are used very rarely, when we need to fiddle with numbers on the very lowest (bitwise) level. We won't need these operators any time soon, as web development has little use of them, but in some special areas, such as cryptography, they are useful. You can read the [Bitwise Operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Bitwise) chapter on MDN when a need arises.
441+
These operators are used very rarely, when we need to fiddle with numbers on the very lowest (bitwise) level. We won't need these operators any time soon, as web development has little use of them, but in some special areas, such as cryptography, they are useful. You can read the [Bitwise Operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#bitwise_operators) chapter on MDN when a need arises.
441442

442443
## Comma
443444

0 commit comments

Comments
 (0)