Skip to content

Commit 48df5a3

Browse files
committed
merging all conflicts
2 parents 0a782ff + 2901e0c commit 48df5a3

File tree

38 files changed

+105
-88
lines changed

38 files changed

+105
-88
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,13 @@ let 1a; // nesmí začínat číslicí
191191
let moje-jméno; // spojovník '-' není v názvu povolen
192192
```
193193

194+
<<<<<<< HEAD
194195
```smart header="Na velikosti záleží"
195196
Proměnné s názvy `jablko` a `JabLKO` jsou dvě různé proměnné.
197+
=======
198+
```smart header="Case matters"
199+
Variables named `apple` and `APPLE` are two different variables.
200+
>>>>>>> 2901e0c64590a67d8a2bde1ea76a514d96f80469
196201
```
197202

198203
````smart header="Nelatinská písmena jsou povolena, ale nedoporučují se"
@@ -297,7 +302,11 @@ const dobaNačítáníStránky = /* doba, kterou trvá načíst webovou stránku
297302
298303
Hodnota proměnné `dobaNačítáníStránky` není známa dříve, než se stránka načte, proto je pojmenována obvyklým způsobem. Je to však konstanta, protože se po přiřazení již nezmění.
299304
305+
<<<<<<< HEAD
300306
Jinými slovy, názvy konstant zapsané velkými písmeny se používají jen pro pojmenování „natvrdo uvedených“ hodnot.
307+
=======
308+
In other words, capital-named constants are only used as aliases for "hard-coded" values.
309+
>>>>>>> 2901e0c64590a67d8a2bde1ea76a514d96f80469
301310
302311
## Pojmenovávejte věci správně
303312

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ for (let i = 0; i < 10; i++) {
268268

269269
From a technical point of view, this is identical to the example above. Surely, we can just wrap the code in an `if` block instead of using `continue`.
270270

271-
But as a side-effect, this created one more level of nesting (the `alert` call inside the curly braces). If the code inside of `if` is longer than a few lines, that may decrease the overall readability.
271+
But as a side effect, this created one more level of nesting (the `alert` call inside the curly braces). If the code inside of `if` is longer than a few lines, that may decrease the overall readability.
272272
````
273273
274274
````warn header="No `break/continue` to the right side of '?'"

1-js/02-first-steps/14-switch/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ switch (a) {
139139
140140
Now both `3` and `5` show the same message.
141141
142-
The ability to "group" cases is a side-effect of how `switch/case` works without `break`. Here the execution of `case 3` starts from the line `(*)` and goes through `case 5`, because there's no `break`.
142+
The ability to "group" cases is a side effect of how `switch/case` works without `break`. Here the execution of `case 3` starts from the line `(*)` and goes through `case 5`, because there's no `break`.
143143
144144
## Type matters
145145

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ function name(parameters, delimited, by, comma) {
522522
523523
To make the code clean and easy to understand, it's recommended to use mainly local variables and parameters in the function, not outer variables.
524524
525-
It is always easier to understand a function which gets parameters, works with them and returns a result than a function which gets no parameters, but modifies outer variables as a side-effect.
525+
It is always easier to understand a function which gets parameters, works with them and returns a result than a function which gets no parameters, but modifies outer variables as a side effect.
526526
527527
Function naming:
528528

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Everything would work the same.
9090

9191

9292
````smart header="Why is there a semicolon at the end?"
93-
You might wonder, why does Function Expression have a semicolon `;` at the end, but Function Declaration does not:
93+
You might wonder, why do Function Expressions have a semicolon `;` at the end, but Function Declarations do not:
9494
9595
```js
9696
function sayHi() {
@@ -144,13 +144,13 @@ function showCancel() {
144144
ask("Do you agree?", showOk, showCancel);
145145
```
146146

147-
In practice, such functions are quite useful. The major difference between a real-life `ask` 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 function usually draws a nice-looking question window. But that's another story.
147+
In practice, such functions are quite useful. The major difference between a real-life `ask` 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 functions usually draw a nice-looking question window. But that's another story.
148148

149149
**The arguments `showOk` and `showCancel` of `ask` are called *callback functions* or just *callbacks*.**
150150

151151
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 "yes" answer, and `showCancel` for "no" answer.
152152

153-
We can use Function Expressions to write the same function much shorter:
153+
We can use Function Expressions to write an equivalent, shorter function:
154154

155155
```js run no-beautify
156156
function ask(question, yes, no) {
@@ -186,7 +186,7 @@ Let's formulate the key differences between Function Declarations and Expression
186186

187187
First, the syntax: how to differentiate between them in the code.
188188

189-
- *Function Declaration:* a function, declared as a separate statement, in the main code flow.
189+
- *Function Declaration:* a function, declared as a separate statement, in the main code flow:
190190

191191
```js
192192
// Function Declaration

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ To fully enable all features of modern JavaScript, we should start scripts with
5555

5656
The directive must be at the top of a script or at the beginning of a function body.
5757

58-
Without `"use strict"`, everything still works, but some features behave in the old-fashion, "compatible" way. We'd generally prefer the modern behavior.
58+
Without `"use strict"`, everything still works, but some features behave in the old-fashioned, "compatible" way. We'd generally prefer the modern behavior.
5959

6060
Some modern features of the language (like classes that we'll study in the future) enable strict mode implicitly.
6161

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Such comments allow us to understand the purpose of the function and use it the
143143

144144
By the way, many editors like [WebStorm](https://www.jetbrains.com/webstorm/) can understand them as well and use them to provide autocomplete and some automatic code-checking.
145145

146-
Also, there are tools like [JSDoc 3](https://github.com/jsdoc3/jsdoc) that can generate HTML-documentation from the comments. You can read more information about JSDoc at <http://usejsdoc.org/>.
146+
Also, there are tools like [JSDoc 3](https://github.com/jsdoc3/jsdoc) that can generate HTML-documentation from the comments. You can read more information about JSDoc at <https://jsdoc.app>.
147147

148148
Why is the task solved this way?
149149
: What's written is important. But what's *not* written may be even more important to understand what's going on. Why is the task solved exactly this way? The code gives no answer.

1-js/03-code-quality/05-testing-mocha/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe("pow", function() {
5151
A spec has three main building blocks that you can see above:
5252

5353
`describe("title", function() { ... })`
54-
: What functionality we're describing. In our case we're describing the function `pow`. Used to group "workers" -- the `it` blocks.
54+
: What functionality we're describing? In our case we're describing the function `pow`. Used to group "workers" -- the `it` blocks.
5555

5656
`it("use case description", function() { ... })`
5757
: In the title of `it` we *in a human-readable way* describe the particular use case, and the second argument is a function that tests it.

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The JavaScript language steadily evolves. New proposals to the language appear r
55

66
Teams behind JavaScript engines have their own ideas about what to implement first. They may decide to implement proposals that are in draft and postpone things that are already in the spec, because they are less interesting or just harder to do.
77

8-
So it's quite common for an engine to implement only the part of the standard.
8+
So it's quite common for an engine to implement only part of the standard.
99

1010
A good page to see the current state of support for language features is <https://kangax.github.io/compat-table/es6/> (it's big, we have a lot to study yet).
1111

@@ -40,9 +40,9 @@ Now the rewritten code is suitable for older JavaScript engines.
4040
4141
Usually, a developer runs the transpiler on their own computer, and then deploys the transpiled code to the server.
4242
43-
Speaking of names, [Babel](https://babeljs.io) is one of the most prominent transpilers out there.
43+
Speaking of names, [Babel](https://babeljs.io) is one of the most prominent transpilers out there.
4444
45-
Modern project build systems, such as [webpack](https://webpack.js.org/), provide means to run transpiler automatically on every code change, so it's very easy to integrate into development process.
45+
Modern project build systems, such as [webpack](https://webpack.js.org/), provide a means to run a transpiler automatically on every code change, so it's very easy to integrate into the development process.
4646
4747
## Polyfills
4848
@@ -69,9 +69,9 @@ if (!Math.trunc) { // if no such function
6969
}
7070
```
7171
72-
JavaScript is a highly dynamic language, scripts may add/modify any functions, even including built-in ones.
72+
JavaScript is a highly dynamic language. Scripts may add/modify any function, even built-in ones.
7373
74-
Two interesting libraries of polyfills are:
74+
Two interesting polyfill libraries are:
7575
- [core js](https://github.com/zloirock/core-js) that supports a lot, allows to include only needed features.
7676
- [polyfill.io](http://polyfill.io) service that provides a script with polyfills, depending on the features and user's browser.
7777
@@ -80,9 +80,9 @@ Two interesting libraries of polyfills are:
8080
8181
In this chapter we'd like to motivate you to study modern and even "bleeding-edge" language features, even if they aren't yet well-supported by JavaScript engines.
8282
83-
Just don't forget to use transpiler (if using modern syntax or operators) and polyfills (to add functions that may be missing). And they'll ensure that the code works.
83+
Just don't forget to use a transpiler (if using modern syntax or operators) and polyfills (to add functions that may be missing). They'll ensure that the code works.
8484
85-
For example, later when you're familiar with JavaScript, you can setup a code build system based on [webpack](https://webpack.js.org/) with [babel-loader](https://github.com/babel/babel-loader) plugin.
85+
For example, later when you're familiar with JavaScript, you can setup a code build system based on [webpack](https://webpack.js.org/) with the [babel-loader](https://github.com/babel/babel-loader) plugin.
8686
8787
Good resources that show the current state of support for various features:
8888
- <https://kangax.github.io/compat-table/es6/> - for pure JavaScript.

1-js/04-object-basics/02-object-copy/article.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ And here's how it's actually stored in memory:
3737

3838
The object is stored somewhere in memory (at the right of the picture), while the `user` variable (at the left) has a "reference" to it.
3939

40-
We may think of an object variable, such as `user`, as like a sheet of paper with the address of the object on it.
40+
We may think of an object variable, such as `user`, like a sheet of paper with the address of the object on it.
4141

4242
When we perform actions with the object, e.g. take a property `user.name`, the JavaScript engine looks at what's at that address and performs the operation on the actual object.
4343

@@ -104,11 +104,9 @@ For comparisons like `obj1 > obj2` or for a comparison against a primitive `obj
104104
105105
So, copying an object variable creates one more reference to the same object.
106106
107-
But what if we need to duplicate an object? Create an independent copy, a clone?
107+
But what if we need to duplicate an object?
108108
109-
That's also doable, but a little bit more difficult, because there's no built-in method for that in JavaScript. But there is rarely a need -- copying by reference is good most of the time.
110-
111-
But if we really want that, then we need to create a new object and replicate the structure of the existing one by iterating over its properties and copying them on the primitive level.
109+
We can create a new object and replicate the structure of the existing one, by iterating over its properties and copying them on the primitive level.
112110
113111
Like this:
114112
@@ -133,7 +131,7 @@ clone.name = "Pete"; // changed the data in it
133131
alert( user.name ); // still John in the original object
134132
```
135133
136-
Also we can use the method [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) for that.
134+
We can also use the method [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign).
137135
138136
The syntax is:
139137
@@ -190,7 +188,7 @@ There are also other methods of cloning an object, e.g. using the [spread syntax
190188
191189
## Nested cloning
192190
193-
Until now we assumed that all properties of `user` are primitive. But properties can be references to other objects. What to do with them?
191+
Until now we assumed that all properties of `user` are primitive. But properties can be references to other objects.
194192
195193
Like this:
196194
```js run
@@ -205,9 +203,7 @@ let user = {
205203
alert( user.sizes.height ); // 182
206204
```
207205
208-
Now it's not enough to copy `clone.sizes = user.sizes`, because the `user.sizes` is an object, it will be copied by reference. So `clone` and `user` will share the same sizes:
209-
210-
Like this:
206+
Now it's not enough to copy `clone.sizes = user.sizes`, because `user.sizes` is an object, and will be copied by reference, so `clone` and `user` will share the same sizes:
211207
212208
```js run
213209
let user = {
@@ -224,10 +220,10 @@ alert( user.sizes === clone.sizes ); // true, same object
224220

225221
// user and clone share sizes
226222
user.sizes.width++; // change a property from one place
227-
alert(clone.sizes.width); // 51, see the result from the other one
223+
alert(clone.sizes.width); // 51, get the result from the other one
228224
```
229225
230-
To fix that, we should use a cloning loop that examines each value of `user[key]` and, if it's an object, then replicate its structure as well. That is called a "deep cloning".
226+
To fix that and make `user` and `clone` truly separate objects, we should use a cloning loop that examines each value of `user[key]` and, if it's an object, then replicate its structure as well. That is called a "deep cloning".
231227
232228
We can use recursion to implement it. Or, to not reinvent the wheel, take an existing implementation, for instance [_.cloneDeep(obj)](https://lodash.com/docs#cloneDeep) from the JavaScript library [lodash](https://lodash.com).
233229

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ Modern engines implement advanced algorithms of garbage collection.
205205

206206
A general book "The Garbage Collection Handbook: The Art of Automatic Memory Management" (R. Jones et al) covers some of them.
207207

208-
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).
208+
If you are familiar with low-level programming, more detailed information about V8's garbage collector is in the article [A tour of V8: Garbage Collection](http://jayconrod.com/posts/55/a-tour-of-v8-garbage-collection).
209209

210-
[V8 blog](https://v8.dev/) 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.
210+
The [V8 blog](https://v8.dev/) also publishes articles about changes in memory management from time to time. Naturally, to learn more about 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 the V8 engineers. I'm saying: "V8", because it is best covered by articles on the internet. For other engines, many approaches are similar, but garbage collection differs in many aspects.
211211

212-
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.
212+
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.

0 commit comments

Comments
 (0)