Skip to content

Commit 0c4adab

Browse files
authored
Merge pull request #1 from iliakan/master
sync with upsteam
2 parents fb99525 + dac2e71 commit 0c4adab

File tree

54 files changed

+96
-86
lines changed

Some content is hidden

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

54 files changed

+96
-86
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Different engines have different "codenames", for example:
3030

3131
The terms above are good to remember, because they are used in developer articles on the internet. We'll use them too. For instance, if "a feature X is supported by V8", then it probably works in Chrome and Opera.
3232

33-
```smart header="How engines work?"
33+
```smart header="How do engines work?"
3434
3535
Engines are complicated. But the basics are easy.
3636

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The `<script>` tag has a few attributes that are rarely used nowadays, but we ca
4747

4848
The `type` attribute: <code>&lt;script <u>type</u>=...&gt;</code>
4949

50-
: The old standard HTML4 required a script to have a type. Usually it was `type="text/javascript"`. The modern HTML standard assumes this `type` by default. No attribute is required.
50+
: The old standard HTML4 required a script to have a type. Usually it was `type="text/javascript"`. It's not required any more. Also, the modern standard totally changed the meaning of this attribute. Now it can be used for Javascript modules. But that's an advanced topic, but we'll talk about modules later in another part of the tutorial.
5151

5252
The `language` attribute: <code>&lt;script <u>language</u>=...&gt;</code>
5353
: This attribute was meant to show the language of the script. As of now, this attribute makes no sense, the language is JavaScript by default. No need to use it.
@@ -61,7 +61,7 @@ Comments before and after scripts.
6161
//--></script>
6262
```
6363

64-
These comments were supposed to hide the code from an old browser that didn't know about a `<script>` tag. But all browsers born in the past 15+ years don't have any issues. We mention it here, because such comments serve as a sign. If you see that somewhere -- that code is probably really old and not worth looking into.
64+
This trick isn't used in modern JavaScript. These comments were used to hide the JavaScript code from old browsers that didn't know about a `<script>` tag. Since browsers born in the last 15 years don't have this issue, this kind of comment can help you identify really old code.
6565

6666

6767
## External scripts

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ const myBirthday = '18.04.1982';
247247
myBirthday = '01.01.2001'; // error, can't reassign the constant!
248248
```
249249
250-
When a programmer is sure that the variable should never change, he can use `const` to guarantee it, and also to clearly show that fact to everyone.
250+
When a programmer is sure that the variable should never change, they can use `const` to guarantee it, and also to clearly show that fact to everyone.
251251
252252
253253
### Uppercase constants

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Yeah, mathematically that's strange. The last result states that "`null` is grea
176176

177177
The reason is that an equality check `==` and comparisons `> < >= <=` work differently. Comparisons convert `null` to a number, hence treat it as `0`. That's why (3) `null >= 0` is true and (1) `null > 0` is false.
178178

179-
On the other hand, the equality check `==` for `undefined` and `null` works by the rule, without any conversions. They equal each other and don't equal anything else. That's why (2) `null == 0` is false.
179+
On the other hand, the equality check `==` for `undefined` and `null` is defined such that, without any conversions, they equal each other and don't equal anything else. That's why (2) `null == 0` is false.
180180

181181
### An incomparable undefined
182182

1-js/02-first-steps/11-logical-operators/article.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,10 @@ When all values are truthy, the last value is returned:
230230
alert( 1 && 2 && 3 ); // 3, the last one
231231
```
232232
233-
````smart header="AND `&&` executes before OR `||`"
234-
The precedence of the AND `&&` operator is higher than OR `||`, so it executes before OR.
233+
````smart header="Precedence of AND `&&` is higher than OR `||`"
234+
The precedence of AND `&&` operator is higher than OR `||`.
235235
236-
In the code below `1 && 0` is calculated first:
237-
238-
```js run
239-
alert( 5 || 1 && 0 ); // 5
240-
```
236+
So the code `a && b || c && d` is essentially the same as if `&&` were in parentheses: `(a && b) || (c && d)`.
241237
````
242238
243239
Just like OR, the AND `&&` operator can sometimes replace `if`.
@@ -303,3 +299,5 @@ There's a little more verbose way to do the same thing -- a built-in `Boolean` f
303299
alert( Boolean("non-empty string") ); // true
304300
alert( Boolean(null) ); // false
305301
```
302+
303+
The precedence of NOT `!` is the highest of all bitwise operators, so it always executes first, before any `&&`, `||`.

1-js/02-first-steps/12-while-for/6-repeat-until-correct/task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ importance: 5
44

55
# Repeat until the input is correct
66

7-
Write a loop which prompts for a number greater than `100`. If the visitor enters another number -- ask him to input again.
7+
Write a loop which prompts for a number greater than `100`. If the visitor enters another number -- ask them to input again.
88

99
The loop must ask for a number until either the visitor enters a number greater than `100` or cancels the input/enters an empty line.
1010

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ More in: <info:variables> and <info:types>.
103103
We're using a browser as a working environment, so basic UI functions will be:
104104

105105
[`prompt(question[, default])`](mdn:api/Window/prompt)
106-
: Ask a `question`, and return either what the visitor entered or `null` if he pressed "cancel".
106+
: Ask a `question`, and return either what the visitor entered or `null` if they pressed "cancel".
107107

108108
[`confirm(question)`](mdn:api/Window/confirm)
109109
: Ask a `question` and suggest to choose between Ok and Cancel. The choice is returned as `true/false`.
110110

111111
[`alert(message)`](mdn:api/Window/alert)
112112
: Output a `message`.
113113

114-
All these functions are *modal*, they pause the code execution and prevent the visitor from interacting with the page until he answers.
114+
All these functions are *modal*, they pause the code execution and prevent the visitor from interacting with the page until they answer.
115115

116116
For instance:
117117

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Any subtle features of the code? Where they are used?
162162

163163
## Summary
164164

165-
An important sign of a good developer is comments: their presence and even their absense.
165+
An important sign of a good developer is comments: their presence and even their absence.
166166

167167
Good comments allow us to maintain the code well, come back to it after a delay and use it more effectively.
168168

1-js/03-code-quality/04-ninja-code/article.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ i = i ? i < 0 ? Math.max(0, len + i) : i : 0;
3434

3535
Cool, right? If you write like that, the developer who comes across this line and tries to understand what is the value of `i` is going to have a merry time. Then come to you, seeking for an answer.
3636

37-
Tell him that shorter is always better. Initiate him into the paths of ninja.
37+
Tell them that shorter is always better. Initiate them into the paths of ninja.
3838

3939
## One-letter variables
4040

@@ -45,11 +45,11 @@ completed.
4545

4646
Another way to code faster is to use single-letter variable names everywhere. Like `a`, `b` or `c`.
4747

48-
A short variable disappears in the code like a real ninja in the forest. No one will be able to find it using "search" of the editor. And even if someone does, he won't be able to "decipher" what the name `a` or `b` means.
48+
A short variable disappears in the code like a real ninja in the forest. No one will be able to find it using "search" of the editor. And even if someone does, they won't be able to "decipher" what the name `a` or `b` means.
4949

5050
...But there's an exception. A real ninja will never use `i` as the counter in a `"for"` loop. Anywhere, but not here. Look around, there are many more exotic letters. For instance, `x` or `y`.
5151

52-
An exotic variable as a loop counter is especially cool if the loop body takes 1-2 pages (make it longer if you can). Then if someone looks deep inside the loop, he won't be able to quickly figure out that the variable named `x` is the loop counter.
52+
An exotic variable as a loop counter is especially cool if the loop body takes 1-2 pages (make it longer if you can). Then if someone looks deep inside the loop, they won't be able to quickly figure out that the variable named `x` is the loop counter.
5353

5454
## Use abbreviations
5555

@@ -153,7 +153,7 @@ function ninjaFunction(elem) {
153153
}
154154
```
155155

156-
A fellow programmer who wants to work with `elem` in the second half of the function will be surprised... Only during the debugging, after examining the code he will find out that he's working with a clone!
156+
A fellow programmer who wants to work with `elem` in the second half of the function will be surprised... Only during the debugging, after examining the code they will find out that he's working with a clone!
157157

158158
Deadly effective even against an experienced ninja. Seen in code regularly.
159159

@@ -204,7 +204,7 @@ There are functions that look like they don't change anything. Like `isReady()`,
204204

205205
**A really beautiful trick is to add a "useful" action to them, besides the main task.**
206206

207-
The expression of dazed surprise on the face of your colleague when he sees a function named `is..`, `check..` or `find...` changing something -- will definitely broaden your boundaries of reason.
207+
The expression of dazed surprise on the face of your colleague when they see a function named `is..`, `check..` or `find...` changing something -- will definitely broaden your boundaries of reason.
208208

209209
**Another way to surprise is to return a non-standard result.**
210210

@@ -228,7 +228,7 @@ Additional actions should not be obvious from the function name. A true ninja co
228228

229229
**Joining several actions into one protects your code from reuse.**
230230

231-
Imagine, another developer wants only to check the email, and not output any message. Your function `validateEmail(email)` that does both will not suit him. So he won't break your meditation by asking anything about it.
231+
Imagine, another developer wants only to check the email, and not output any message. Your function `validateEmail(email)` that does both will not suit them. So they won't break your meditation by asking anything about it.
232232

233233
## Summary
234234

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 his 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/) or [brunch](http://brunch.io/) provide means to run transpiler automatically on every code change, so that doesn't involve any time loss from our side.
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/) or [brunch](http://brunch.io/) provide means to run transpiler automatically on every code change, so that doesn't involve any time loss from our side.
2323

2424
2. Second, the polyfill.
2525

0 commit comments

Comments
 (0)