Skip to content

Commit 2aebe4b

Browse files
committed
Merge remote-tracking branch 'refs/remotes/iliakan/master'
2 parents 21bc29e + 1fb7296 commit 2aebe4b

File tree

17 files changed

+154
-128
lines changed

17 files changed

+154
-128
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ Different engines have different "codenames", for example:
2828
- [Gecko](https://en.wikipedia.org/wiki/Gecko_(software)) -- in Firefox.
2929
- ...There are other codenames like "Trident", "Chakra" for different versions of IE, "ChakraCore" for Microsoft Edge, "Nitro" and "SquirrelFish" for Safari etc.
3030

31-
These terms above are good to remember, because they are used in developer articles in 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.
31+
The terms above are good to remember, because they are used in developer articles in 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 the engines work?"
33+
```smart header="How engines work?"
3434
3535
Engines are complicated. But the basics are easy.
3636
3737
1. The script is written and distributed as a plain text (can be compressed/optimized by so-called "javascript minifiers").
3838
2. The engine (embedded if it's a browser) reads the script ("parses") and converts ("compiles") it to the machine language.
3939
3. And then it runs, pretty fast.
4040
41-
The engine applies optimizations on every stage of the process. It even watches the script as it runs, analyzes the data which flows through it and applies optimizations to the machine-code basing on that knowledge.
41+
The engine applies optimizations on every stage of the process. It even watches the script as it runs, analyzes the data which flows through it and applies optimizations to the machine-code basing on that knowledge. That's why the code runs fast.
4242
```
4343

4444
## What can in-browser JavaScript do?
@@ -57,7 +57,7 @@ For instance, in-browser JavaScript is able to:
5757
- Get and set cookies, ask questions to the visitor, show messages.
5858
- Remember the data on the browser side ("local storage").
5959

60-
## What can in-browser JavaScript NOT do?
60+
## What in-browser JavaScript can NOT do?
6161

6262
JavaScript abilities in the browser are limited for the sake of the user's safety. The aim is to prevent an evil webpage from accessing private information or harming the user's data.
6363

@@ -89,9 +89,9 @@ There are at least *three* great things about JavaScript:
8989
+ Supported by all major browsers and enabled by default.
9090
```
9191

92-
Combined, these 3 things only exist in JavaScript and no other browser technology.
92+
Combined, these 3 things exist only in JavaScript and no other browser technology.
9393

94-
That's what makes JavaScript unique. That's why it is the most widespread way of creating browser interfaces.
94+
That's what makes JavaScript unique. That's why it's the most widespread tool to create browser interfaces.
9595

9696
While planning to learn a new technology, it's beneficial to check its perspectives. So let's move on to the modern trends that include new languages and browser abilities.
9797

1-js/01-getting-started/2-code-editors/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ There are two archetypes: IDE and lightweight editors. Many people feel comforta
1010

1111
The term [IDE](https://en.wikipedia.org/wiki/Integrated_development_environment) (Integrated Development Environment) means a powerful editor with many features that usually operates on a "whole project". As said, that's not just an editor, but a full-scale "development environment".
1212

13-
An IDE loads the project (can be many files), and then allows to navigate between files, provides autocompletion based on the whole project, integrates with version management system (like [git](https://git-scm.com/)), with testing environment and other "project-level" stuff.
13+
An IDE loads the project (can be many files), and then allows navigation between files, provides autocompletion based on the whole project, integrates with version management system (like [git](https://git-scm.com/)), with testing environment and other "project-level" stuff.
1414

1515
If you haven't considered selecting an IDE, look at the following variants:
1616

1717
- IntelliJ editors: [WebStorm](http://www.jetbrains.com/webstorm/) for frontend development and [PHPStorm (PHP)](http://www.jetbrains.com/phpstorm/), [IDEA (Java)](http://www.jetbrains.com/idea/), [RubyMine (Ruby)](http://www.jetbrains.com/ruby/) and other if you need additional languages.
1818
- Visual Studio is fine if you're a .NET developer, and a free version is available ([Visual Studio Community](https://www.visualstudio.com/vs/community/))
1919
- Eclipse-based products, like [Aptana](http://www.aptana.com/) and Zend Studio.
20-
- [Komodo IDE](http://www.activestate.com/komodo-ide) and it's lightweight free version [Komodo Edit](http://www.activestate.com/komodo-edit).
20+
- [Komodo IDE](http://www.activestate.com/komodo-ide) and its lightweight free version [Komodo Edit](http://www.activestate.com/komodo-edit).
2121
- [Netbeans](http://netbeans.org/).
2222

2323
All of the IDEs listed above are available on both Windows and Mac, and the IDEs other than Visual Studio are also available on Linux.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ For instance:
3737
```
3838

3939
```online
40-
You can run the example clicking on a "Play" button in it's right-top corner.
40+
You can run the example by clicking on the "Play" button in its right-top corner.
4141
```
4242

4343
The `<script>` tag contains JavaScript code which is automatically executed when the browser meets the tag.
@@ -49,7 +49,7 @@ The `<script>` tag has a few attributes that are rarely used nowadays, but we ca
4949

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

52-
: The old standard HTML4 required a script to have the type. Usually it was `type="text/javascript"`. The modern HTML standard assumes this `type` by default, no attribute is required.
52+
: 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.
5353

5454
The `language` attribute: <code>&lt;script <u>language</u>=...&gt;</code>
5555
: 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.
@@ -95,7 +95,7 @@ To attach several scripts, use multiple tags:
9595
```
9696

9797
```smart
98-
As a rule, only simplest scripts are put into HTML. More complex ones reside in separate files.
98+
As a rule, only the simplest scripts are put into HTML. More complex ones reside in separate files.
9999
100100
The benefit of a separate file is that the browser will download it and then store in its [cache](https://en.wikipedia.org/wiki/Web_cache).
101101

1-js/02-first-steps/02-structure/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ alert('Hello');
114114
alert('World'); // This comment follows the statement
115115
```
116116

117-
**Multiline comments start with a forward slash and an asterisk <code>"/&#42;"</code> and end with an asterisk and a forward slash <code>"&#42;/"</code>.**
117+
**Multiline comments start with a forward slash and an asterisk <code>/&#42;</code> and end with an asterisk and a forward slash <code>&#42;/</code>.**
118118

119119
Like this:
120120

1-js/02-first-steps/03-strict-mode/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ alert("some code");
4545
Only comments may appear above `"use strict"`.
4646
````
4747
48-
4948
```smart header="`use strict` for functions"
5049
We will learn functions (a way to group commands) soon.
5150
@@ -59,6 +58,7 @@ It is recommended to always start a script with `"use strict"`, for the followin
5958
6059
1. First, all modern browsers support it. Only outdated ones like Internet Explorer 9 and below do not.
6160
2. Second, the modern JavaScript actually forces us into the strict mode. There are several modern language features like "classes" and "modules" that enable strict mode automatically. So, it's hard to evade it.
61+
3. The last, but not the least: strict mode is the modern mode. Makes the language a little bit better in few aspects. We'll see that as we study more language features.
6262
6363
Here in the tutorial, all code (where not explicitly noted otherwise) works in `"use strict"`. We concentrate on modern JavaScript. But there will be notes about what happens without `"use strict"`, so that you can understand what's going on if you forget it or if you're working with an outdated script that doesn't have it.
6464
@@ -67,4 +67,4 @@ Here in the tutorial, all code (where not explicitly noted otherwise) works in `
6767
- The `"use strict"` directive switches the engine to the "modern" mode, changing the behavior of some built-in features.
6868
- Several modern features of the language enable `"use strict"` implicitly, so it's quite hard to evade it.
6969
70-
It's always recommended to start scripts with `"use strict"`. All examples in this book assume so, unless (very rarely) specified otherwise.
70+
It's always recommended to start scripts with `"use strict"`. All examples in this tutorial assume so, unless (very rarely) specified otherwise.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ alert( null >= 0 ); // (3) *!*true*/!*
176176

177177
Yeah, mathematically that's strange. The last result states that "`null` is equal or greater than zero". Then one of the comparisons above must be correct, but they are both falsy.
178178

179-
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 (1) `null >= 0` is true and (3) `null > 0` is false.
179+
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.
180180

181-
From 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.
181+
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.
182182

183183
### An incomparable undefined
184184

@@ -192,7 +192,7 @@ alert( undefined == 0 ); // false (3)
192192

193193
Why does it dislike a zero so much? Always false!
194194

195-
We've got such result, because:
195+
We've got these results because:
196196

197197
- Comparisons `(1)` and `(2)` return `false` because `undefined` gets converted to `NaN`. And `NaN` is a special numeric value which returns `false` for all comparisons.
198198
- The equality check `(3)` returns `false`, because `undefined` only equals `null` and no other value.
@@ -201,7 +201,7 @@ We've got such result, because:
201201

202202
Why did we observe these examples? Should we remember these pecularities all the time? Well, not really. Actually, these tricky things will gradually become familiar over the time, but there's a solid way to evade any problems with them.
203203

204-
Just treat any comparison with `undefined/null` except the strict equality `===` with an exceptional care.
204+
Just treat any comparison with `undefined/null` except the strict equality `===` with exceptional care.
205205

206206
Don't use comparisons `>= > < <=` with a variable which may be `null/undefined`, unless you are really sure what you're doing. If a variable can have such values, then check for them separately.
207207

1-js/02-first-steps/10-ifelse/article.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ It is recommended to use figure brackets every time with `if`, even if there's o
3737

3838
The `if (…)` operator evaluates the expression in parentheses and converts it to the boolean type.
3939

40-
Let's recall the conversion rules:
40+
Let's recall the conversion rules from the chapter <info:type-conversions>:
4141

42-
- A number `0`, an empty string `""`, `null`, `undefined` and `NaN` are `false`,
43-
- Other values -- `true`.
42+
- A number `0`, an empty string `""`, `null`, `undefined` and `NaN` become `false`. Because of that they are called "falsy" values.
43+
- Other values become `true`, so they are called "truthy".
4444

4545
So, the code under this condition would never execute:
4646

1-js/04-object-basics/02-garbage-collection/article.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,11 @@ JavaScript engines apply many optimizations to make it run faster and not affect
189189

190190
Some of the optimizations:
191191

192-
- **Generational collection** -- objects are split into two sets: "new ones" and "old ones". Many objects appear, then do their job and die fast, so they can be cleaned up aggressively. Those that survive for long enough, become "old".
193-
- **Incremental collection** -- if there are many objects, and we try to walk and mark the whole object set at once, it may take some time and introduce visible delays in the execution. So the engine tries to split the job into pieces. Then pieces are executed one at a time. That requires some extra bookkeeping between them to track changes.
192+
- **Generational collection** -- objects are split into two sets: "new ones" and "old ones". Many objects appear, do their job and die fast, they can be cleaned up aggressively. Those that survive for long enough, become "old" and are examined less often.
193+
- **Incremental collection** -- if there are many objects, and we try to walk and mark the whole object set at once, it may take some time and introduce visible delays in the execution. So the engine tries to split the garbage collection into pieces. Then the pieces are executed one by one, separately. That requires some extra bookkeeping between them to track changes, but we have many tiny delays instead of a big one.
194194
- **Idle-time collection** -- the garbage collector tries to run only while the CPU is idle, to reduce the possible effect on the execution.
195195

196-
There are other optimizations and flavours of garbage collection algorithms. As much as I'd like to describe them here, I have to hold off, because different engines implement different tweaks and techniques.
197-
198-
And -- what's even more important, things change as engines develop, so going really deep "in advance", without a real need is probably not worth that. Unless, of course, it is a matter of pure interest, then there will be some links for you below.
196+
There are other optimizations and flavours of garbage collection algorithms. As much as I'd like to describe them here, I have to hold off, because different engines implement different tweaks and techniques. And -- what's even more important, things change as engines develop, so going deeper "in advance", without a real need is probably not worth that. Unless, of course, it is a matter of pure interest, then there will be some links for you below.
199197

200198
## Summary
201199

@@ -209,8 +207,8 @@ Modern engines implement advanced algorithms of garbage collection.
209207

210208
A general book "The Garbage Collection Handbook: The Art of Automatic Memory Management" (R. Jones at al) covers some of them.
211209

212-
If you are familiar with low-level programming, the more detailed information about V8 garbage collector is in the article [A tour of V8: Garbage Collection](http://jayconrod.com/posts/55/a-tour-of-v8-garbage-collection).
210+
If you are familiar with low-level programming, the more detailed information about V8 garbage collector is in the article [A tour of V8: Garbage Collection](http://jayconrod.com/posts/55/a-tour-of-v8-garbage-collection).
213211

214-
[V8 blog](http://v8project.blogspot.com/) also publishes articles about changes in memory management from time to time. Naturally, to learn the garbage collection, you'd better prepare by learning about V8 internals in general and read the blog of [Vyacheslav Egorov](http://mrale.ph) who worked as one of V8 engineers. I'm saying: "V8", because it is best covered with articles in the internet. For other engines, many approaches are similar, but garbage collection differs in many aspects.
212+
[V8 blog](http://v8project.blogspot.com/) also publishes articles about changes in memory management from time to time. Naturally, to learn the garbage collection, you'd better prepare by learning about V8 internals in general and read the blog of [Vyacheslav Egorov](http://mrale.ph) who worked as one of V8 engineers. I'm saying: "V8", because it is best covered with articles in the internet. For other engines, many approaches are similar, but garbage collection differs in many aspects.
215213

216214
In-depth knowledge of engines is good when you need low-level optimizations. It would be wise to plan that as the next step after you're familiar with the language.

1-js/04-object-basics/03-symbol/article.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,14 @@ alert( clone[id] ); // 123
159159
There's no paradox here. That's by design. The idea is that when we clone an object or merge objects, we usually want *all* properties to be copied (including symbols like `id`).
160160

161161
````smart header="Property keys of other types are coerced to strings"
162-
We can only use strings or symbols as keys in objects. Other types are coerced to strings.
162+
We can only use strings or symbols as keys in objects. Other types are converted to strings.
163163
164-
For instance:
164+
For instance, a number `0` becomes a string `"0"` when used as a property key:
165165
166166
```js run
167167
let obj = {
168168
0: "test" // same as "0": "test"
169-
}
169+
};
170170
171171
// both alerts access the same property (the number 0 is converted to string "0")
172172
alert( obj["0"] ); // test
@@ -176,11 +176,11 @@ alert( obj[0] ); // test (same property)
176176

177177
## Global symbols
178178

179-
Normally, all symbols are different. But sometimes we want same-named symbols to be the same.
179+
As we've seen, usually all symbols are different, even if they have the same name. But sometimes we want same-named symbols to be same entities.
180180

181181
For instance, different parts of our application want to access symbol `"id"` meaning exactly the same property.
182182

183-
To achieve that, there exists a *global symbol registry*. We can create symbols in it and and access them later, and it guarantees that repeated accesses by the same name return exactly the same symbol.
183+
To achieve that, there exists a *global symbol registry*. We can create symbols in it and access them later, and it guarantees that repeated accesses by the same name return exactly the same symbol.
184184

185185
In order to create or read a symbol in the registry, use `Symbol.for(name)`.
186186

@@ -230,7 +230,9 @@ alert( Symbol.keyFor(Symbol.for("name")) ); // name, global symbol
230230
alert( Symbol.keyFor(Symbol("name2")) ); // undefined, non-global symbol
231231
```
232232

233-
For non-global symbols, the name is only used for debugging purposes.
233+
So, for global symbols the name may be indeed helpful, as we can get a symbol by id.
234+
235+
And for non-global symbols the name is only used for debugging purposes, like printing out a symbol.
234236

235237
## System symbols
236238

1-js/05-data-types/08-keys-values-entries/article.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Object.keys, values, entries
33

4-
Let's step away from the indivitual data structures and talk about the iterations over them.
4+
Let's step away from the individual data structures and talk about the iterations over them.
55

66
In the previous chapter we saw methods `map.keys()`, `map.values()`, `map.entries()`.
77

@@ -63,8 +63,9 @@ for(let value of Object.values(user)) {
6363
}
6464
```
6565

66-
```smart header="`Object.keys/values/entries` ignore symbolic properties"
67-
Just like `for..in` loop, these methods ignore properties that use `Symbol(...)` as keys.
66+
## Object.keys/values/entries ignore symbolic properties
67+
68+
Just like a `for..in` loop, these methods ignore properties that use `Symbol(...)` as keys.
6869

6970
Usually that's convenient. But if we want symbolic keys too, then there's a separate method [Object.getOwnPropertySymbols](mdn:js/Object/getOwnPropertySymbols) that returns an array of only symbolic keys. Also, the method [Reflect.ownKeys(obj)](mdn:js/Reflect/ownKeys) returns *all* keys.
7071
```

1-js/07-object-oriented-programming/01-property-descriptors/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ user.name = "Alice"; // Error
143143

144144
## Non-enumerable
145145

146-
Now let's a custom `toString` to `user`.
146+
Now let's add a custom `toString` to `user`.
147147

148148
Normally, a built-in `toString` for objects is non-enumerable, it does not show up in `for..in`. But if we add `toString` of our own, then by default it shows up in `for..in`.
149149

0 commit comments

Comments
 (0)