Skip to content

Commit c04a45c

Browse files
committed
merging all conflicts
2 parents 6b59521 + b09e38c commit c04a45c

File tree

63 files changed

+505
-254
lines changed

Some content is hidden

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

63 files changed

+505
-254
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ sftp-config.json
2121
Thumbs.db
2222

2323

24+
/svgs

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ Prohlížeč má zabudovaný engine, který se někdy nazývá „virtuální st
2424

2525
Různé enginy mají různá „kódová označení“. Například:
2626

27+
<<<<<<< HEAD
2728
- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- v Chrome a Opeře.
2829
- [SpiderMonkey](https://cs.wikipedia.org/wiki/SpiderMonkey) -- ve Firefoxu.
2930
- Existují i jiná krycí jména, například „Chakra“ pro Internet Explorer, „ChakraCore“ pro Microsoft Edge, „Nitro“ a „SquirrelFish“ pro Safari, a tak dále.
31+
=======
32+
- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- in Chrome and Opera.
33+
- [SpiderMonkey](https://en.wikipedia.org/wiki/SpiderMonkey) -- in Firefox.
34+
- ...There are other codenames like "Chakra" for IE, "JavaScriptCore", "Nitro" and "SquirrelFish" for Safari, etc.
35+
>>>>>>> b09e38c5573346c401a9f9f7410b4ff9be5f4115
3036
3137
Výše uvedené pojmy je dobré si pamatovat, protože se používají ve vývojářských článcích na internetu. Budeme je používat i my. Například „vlastnost X je podporována ve V8“ znamená, že pravděpodobně bude fungovat v Chrome a Opeře.
3238

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

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ alert(3 +
4646
+ 2);
4747
```
4848

49-
The code outputs `6` because JavaScript does not insert semicolons here. It is intuitively obvious that if the line ends with a plus `"+"`, then it is an "incomplete expression", so the semicolon is not required. And in this case that works as intended.
49+
The code outputs `6` because JavaScript does not insert semicolons here. It is intuitively obvious that if the line ends with a plus `"+"`, then it is an "incomplete expression", so a semicolon there would be incorrect. And in this case, that works as intended.
5050

5151
**But there are situations where JavaScript "fails" to assume a semicolon where it is really needed.**
5252

@@ -56,40 +56,36 @@ Errors which occur in such cases are quite hard to find and fix.
5656
If you're curious to see a concrete example of such an error, check this code out:
5757
5858
```js run
59-
[1, 2].forEach(alert)
59+
alert("Hello");
60+
61+
[1, 2].forEach(alert);
6062
```
6163
62-
No need to think about the meaning of the brackets `[]` and `forEach` yet. We'll study them later. For now, just remember the result of the code: it shows `1` then `2`.
64+
No need to think about the meaning of the brackets `[]` and `forEach` yet. We'll study them later. For now, just remember the result of running the code: it shows `Hello`, then `1`, then `2`.
6365
64-
Now, let's add an `alert` before the code and *not* finish it with a semicolon:
66+
Now let's remove the semicolon after the `alert`:
6567
6668
```js run no-beautify
67-
alert("There will be an error")
69+
alert("Hello")
6870
69-
[1, 2].forEach(alert)
71+
[1, 2].forEach(alert);
7072
```
7173
72-
Now if we run the code, only the first `alert` is shown and then we have an error!
73-
74-
But everything is fine again if we add a semicolon after `alert`:
75-
```js run
76-
alert("All fine now");
74+
The difference compared to the code above is only one character: the semicolon at the end of the first line is gone.
7775
78-
[1, 2].forEach(alert)
79-
```
76+
If we run this code, only the first `Hello` shows (and there's an error, you may need to open the console to see it). There are no numbers any more.
8077
81-
Now we have the "All fine now" message followed by `1` and `2`.
78+
That's because JavaScript does not assume a semicolon before square brackets `[...]`. So, the code in the last example is treated as a single statement.
8279
83-
84-
The error in the no-semicolon variant occurs because JavaScript does not assume a semicolon before square brackets `[...]`.
85-
86-
So, because the semicolon is not auto-inserted, the code in the first example is treated as a single statement. Here's how the engine sees it:
80+
Here's how the engine sees it:
8781
8882
```js run no-beautify
89-
alert("There will be an error")[1, 2].forEach(alert)
83+
alert("Hello")[1, 2].forEach(alert);
9084
```
9185
92-
But it should be two separate statements, not one. Such a merging in this case is just wrong, hence the error. This can happen in other situations.
86+
Looks weird, right? Such merging in this case is just wrong. We need to put a semicolon after `alert` for the code to work correctly.
87+
88+
This can happen in other situations also.
9389
````
9490

9591
We recommend putting semicolons between statements even if they are separated by newlines. This rule is widely adopted by the community. Let's note once again -- *it is possible* to leave out semicolons most of the time. But it's safer -- especially for a beginner -- to use them.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Now, we can put some data into it by using the assignment operator `=`:
2424
let message;
2525

2626
*!*
27-
message = 'Hello'; // store the string
27+
message = 'Hello'; // store the string 'Hello' in the variable named message
2828
*/!*
2929
```
3030

1-js/02-first-steps/05-types/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Special numeric values formally belong to the "number" type. Of course they are
6464

6565
We'll see more about working with numbers in the chapter <info:number>.
6666

67-
## BigInt
67+
## BigInt [#bigint-type]
6868

6969
In JavaScript, the "number" type cannot represent integer values larger than <code>(2<sup>53</sup>-1)</code> (that's `9007199254740991`), or less than <code>-(2<sup>53</sup>-1)</code> for negatives. It's a technical limitation caused by their internal representation.
7070

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ In school maths, we write that as a<sup>b</sup>.
6363
For instance:
6464

6565
```js run
66-
alert( 2 ** 2 ); // 2² = 4
67-
alert( 2 ** 3 ); // 2³ = 8
66+
alert( 2 ** 2 ); // 2² = 4
67+
alert( 2 ** 3 ); // 2³ = 8
6868
alert( 2 ** 4 ); // 2⁴ = 16
6969
```
7070

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Let's examine the `for` statement part-by-part:
106106

107107
| part | | |
108108
|-------|----------|----------------------------------------------------------------------------|
109-
| begin | `i = 0` | Executes once upon entering the loop. |
109+
| begin | `let i = 0` | Executes once upon entering the loop. |
110110
| condition | `i < 3`| Checked before every loop iteration. If false, the loop stops. |
111111
| body | `alert(i)`| Runs again and again while the condition is truthy. |
112112
| step| `i++` | Executes after the body on each iteration. |
@@ -377,7 +377,7 @@ label: {
377377
}
378378
```
379379
380-
...Although, 99.9% of the time `break` used is inside loops, as we've seen in the examples above.
380+
...Although, 99.9% of the time `break` is used inside loops, as we've seen in the examples above.
381381
382382
A `continue` is only possible from inside a loop.
383383
````

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

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ function showMessage() {
2020
}
2121
```
2222

23-
The `function` keyword goes first, then goes the *name of the function*, then a list of *parameters* between the parentheses (comma-separated, empty in the example above) and finally the code of the function, also named "the function body", between curly braces.
23+
The `function` keyword goes first, then goes the *name of the function*, then a list of *parameters* between the parentheses (comma-separated, empty in the example above, we'll see examples later) and finally the code of the function, also named "the function body", between curly braces.
2424

2525
```js
26-
function name(parameters) {
26+
function name(parameter1, parameter2, ... parameterN) {
2727
...body...
2828
}
2929
```
@@ -137,26 +137,23 @@ It's a good practice to minimize the use of global variables. Modern code has fe
137137

138138
## Parameters
139139

140-
We can pass arbitrary data to functions using parameters (also called *function arguments*) .
140+
We can pass arbitrary data to functions using parameters.
141141

142142
In the example below, the function has two parameters: `from` and `text`.
143143

144144
```js run
145-
function showMessage(*!*from, text*/!*) { // arguments: from, text
145+
function showMessage(*!*from, text*/!*) { // parameters: from, text
146146
alert(from + ': ' + text);
147147
}
148148

149-
*!*
150-
showMessage('Ann', 'Hello!'); // Ann: Hello! (*)
151-
showMessage('Ann', "What's up?"); // Ann: What's up? (**)
152-
*/!*
149+
*!*showMessage('Ann', 'Hello!');*/!* // Ann: Hello! (*)
150+
*!*showMessage('Ann', "What's up?");*/!* // Ann: What's up? (**)
153151
```
154152
155153
When the function is called in lines `(*)` and `(**)`, the given values are copied to local variables `from` and `text`. Then the function uses them.
156154
157155
Here's one more example: we have a variable `from` and pass it to the function. Please note: the function changes `from`, but the change is not seen outside, because a function always gets a copy of the value:
158156

159-
160157
```js run
161158
function showMessage(from, text) {
162159

@@ -175,19 +172,31 @@ showMessage(from, "Hello"); // *Ann*: Hello
175172
alert( from ); // Ann
176173
```
177174
175+
When a value is passed as a function parameter, it's also called an *argument*.
176+
177+
In other words, to put these terms straight:
178+
179+
- A parameter is the variable listed inside the parentheses in the function declaration (it's a declaration time term)
180+
- An argument is the value that is passed to the function when it is called (it's a call time term).
181+
182+
We declare functions listing their parameters, then call them passing arguments.
183+
184+
In the example above, one might say: "the function `showMessage` is declared with two parameters, then called with two arguments: `from` and `"Hello"`".
185+
186+
178187
## Default values
179188
180-
If a parameter is not provided, then its value becomes `undefined`.
189+
If a function is called, but an argument is not provided, then the corresponding value becomes `undefined`.
181190
182191
For instance, the aforementioned function `showMessage(from, text)` can be called with a single argument:
183192
184193
```js
185194
showMessage("Ann");
186195
```
187196
188-
That's not an error. Such a call would output `"*Ann*: undefined"`. There's no `text`, so it's assumed that `text === undefined`.
197+
That's not an error. Such a call would output `"*Ann*: undefined"`. As the value for `text` isn't passed, it becomes `undefined`.
189198
190-
If we want to use a "default" `text` in this case, then we can specify it after `=`:
199+
We can specify the so-called "default" (to use if omitted) value for a parameter in the function declaration, using `=`:
191200
192201
```js run
193202
function showMessage(from, *!*text = "no text given"*/!*) {
@@ -211,19 +220,23 @@ function showMessage(from, text = anotherFunction()) {
211220
```smart header="Evaluation of default parameters"
212221
In JavaScript, a default parameter is evaluated every time the function is called without the respective parameter.
213222

214-
In the example above, `anotherFunction()` is called every time `showMessage()` is called without the `text` parameter.
223+
In the example above, `anotherFunction()` isn't called at all, if the `text` parameter is provided.
224+
225+
On the other hand, it's independently called every time when `text` is missing.
215226
```
216227

217228
### Alternative default parameters
218229

219-
Sometimes it makes sense to set default values for parameters not in the function declaration, but at a later stage, during its execution.
230+
Sometimes it makes sense to assign default values for parameters not in the function declaration, but at a later stage.
220231

221-
To check for an omitted parameter, we can compare it with `undefined`:
232+
We can check if the parameter is passed during the function execution, by comparing it with `undefined`:
222233

223234
```js run
224235
function showMessage(text) {
236+
// ...
237+
225238
*!*
226-
if (text === undefined) {
239+
if (text === undefined) { // if the parameter is missing
227240
text = 'empty message';
228241
}
229242
*/!*
@@ -237,18 +250,18 @@ showMessage(); // empty message
237250
...Or we could use the `||` operator:
238251
239252
```js
240-
// if text parameter is omitted or "" is passed, set it to 'empty'
241253
function showMessage(text) {
254+
// if text is undefined or otherwise falsy, set it to 'empty'
242255
text = text || 'empty';
243256
...
244257
}
245258
```
246259
247-
Modern JavaScript engines support the [nullish coalescing operator](info:nullish-coalescing-operator) `??`, it's better when falsy values, such as `0`, are considered regular:
260+
Modern JavaScript engines support the [nullish coalescing operator](info:nullish-coalescing-operator) `??`, it's better when most falsy values, such as `0`, should be considered "normal":
248261
249262
```js run
250-
// if there's no "count" parameter, show "unknown"
251263
function showCount(count) {
264+
// if count is undefined or null, show "unknown"
252265
alert(count ?? "unknown");
253266
}
254267

1-js/03-code-quality/01-debugging-chrome/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Debugging in Chrome
1+
# Debugging in the browser
22

33
Before writing more complex code, let's talk about debugging.
44

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Here, in this chapter, our purpose is to get the gist of how they work, and thei
2222

2323
## Transpilers
2424

25-
A [transpiler](https://en.wikipedia.org/wiki/Source-to-source_compiler) is a special piece of software that can parse ("read and understand") modern code, and rewrite it using older syntax constructs, so that the result would be the same.
25+
A [transpiler](https://en.wikipedia.org/wiki/Source-to-source_compiler) is a special piece of software that translates source code to another source code. It can parse ("read and understand") modern code and rewrite it using older syntax constructs, so that it'll also work in outdated engines.
2626

2727
E.g. JavaScript before year 2020 didn't have the "nullish coalescing operator" `??`. So, if a visitor uses an outdated browser, it may fail to understand the code like `height = height ?? 100`.
2828

0 commit comments

Comments
 (0)