Skip to content

Commit 8e39b74

Browse files
authored
Merge branch 'master' into An-Introduction-to-JavaScript
2 parents 9a89f3f + 9bd2dc2 commit 8e39b74

File tree

122 files changed

+1373
-941
lines changed

Some content is hidden

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

122 files changed

+1373
-941
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Různé enginy mají různá „kódová označení“. Například:
2626

2727
- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- v Chrome a Opeře.
2828
- [SpiderMonkey](https://cs.wikipedia.org/wiki/SpiderMonkey) -- ve Firefoxu.
29-
- Existují i jiná krycí jména, například „Trident“ a „Chakra“ pro různé verze Internet Exploreru, „ChakraCore“ pro Microsoft Edge, „Nitro“ a „SquirrelFish“ pro Safari, a tak dále.
29+
- 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.
3030

3131
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.
3232

@@ -110,11 +110,12 @@ Příklady takových jazyků:
110110
- [TypeScript](http://www.typescriptlang.org/) se soustředí na přidání „striktního, silně typovaného systému“, aby zjednodušil vývoj a podporu složitých systémů. Vyvinula jej firma Microsoft.
111111
- [Flow](http://flow.org/) rovněž přidává typovací systém, ale jiným způsobem. Vyvinul jej Facebook.
112112
- [Dart](https://www.dartlang.org/) je samostatný jazyk se svým vlastním enginem, který běží v prostředích mimo prohlížeč (např. v mobilních aplikacích), ale i ten může být transpilován do JavaScriptu. Vyvinut firmou Google.
113+
- [Brython](https://brython.info/) je transpiler Pythonu do JavaScriptu, který umožňuje psát aplikace v čistém Pythonu bez JavaScriptu.
113114

114115
Jsou i další. Samozřejmě i když používáme některý z transpilovaných jazyků, měli bychom znát i JavaScript, abychom skutečně porozuměli tomu, co se děje.
115116

116117
## Shrnutí
117118

118119
- JavaScript byl původně vytvořen jako jazyk určený výhradně pro prohlížeč, ale dnes se používá i v mnoha jiných prostředích.
119120
- Dnes si JavaScript vydobyl unikátní postavení jako nejrozsáhleji přijímaný prohlížečový jazyk s plnou integrací s HTML/CSS.
120-
- Existuje mnoho jazyků, které jsou „transpilovány“ do JavaScriptu a poskytují určité vlastnosti. Až zvládnete JavaScript, doporučujeme vám, abyste se na ně alespoň krátce podívali.
121+
- Existuje mnoho jazyků, které jsou „transpilovány“ do JavaScriptu a poskytují určité vlastnosti. Až zvládnete JavaScript, doporučujeme vám, abyste se na ně alespoň krátce podívali.
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11

2-
# Manuals and specifications
2+
# Manuály a specifikace
33

4-
This book is a *tutorial*. It aims to help you gradually learn the language. But once you're familiar with the basics, you'll need other sources.
4+
Tato kniha je *tutoriál*, jehož cílem je pomoci vám postupně se naučit jazyk. Až ovšem budete znát základy, budete potřebovat i jiné zdroje.
55

6-
## Specification
6+
## Specifikace
77

8-
[The ECMA-262 specification](https://www.ecma-international.org/publications/standards/Ecma-262.htm) contains the most in-depth, detailed and formalized information about JavaScript. It defines the language.
8+
[Specifikace ECMA-262](https://www.ecma-international.org/publications/standards/Ecma-262.htm) obsahuje nejhlubší, nejpodrobnější a nejformalizovanější informace o JavaScriptu. Ta definuje tento jazyk.
99

10-
But being that formalized, it's difficult to understand at first. So if you need the most trustworthy source of information about the language details, the specification is the right place. But it's not for everyday use.
10+
Avšak právě kvůli této vysoké formálnosti je obtížné jí na první pohled porozumět. Potřebujete-li tedy co nejdůvěryhodnější zdroj informací o detailech JavaScriptu, tato specifikace je správné místo. Ke každodennímu použití se však nehodí.
1111

12-
A new specification version is released every year. In-between these releases, the latest specification draft is at <https://tc39.es/ecma262/>.
12+
Každý rok se vydává nová verze specifikace. Poslední návrh nového vydání specifikace najdete na <https://tc39.es/ecma262/>.
1313

14-
To read about new bleeding-edge features, including those that are "almost standard" (so-called "stage 3"), see proposals at <https://github.com/tc39/proposals>.
14+
Chcete-li si přečíst o zbrusu nových vlastnostech, včetně těch, které jsou „téměř standardem“ (tzv. „3. stadium“), viz propozice na <https://github.com/tc39/proposals>.
1515

16-
Also, if you're in developing for the browser, then there are other specs covered in the [second part](info:browser-environment) of the tutorial.
16+
Pokud vyvíjíte pro prohlížeč, existují i další specifikace uvedené ve [druhé části](info:browser-environment) tutoriálu.
1717

18-
## Manuals
18+
## Manuály
1919

20-
- **MDN (Mozilla) JavaScript Reference** is a manual with examples and other information. It's great to get in-depth information about individual language functions, methods etc.
20+
- **MDN (Mozilla) JavaScript Reference** je manuál s příklady a dalšími informacemi. Výborně poslouží pro získání podrobných informací o jednotlivých funkcích jazyka, metodách atd.
2121

22-
One can find it at <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference>.
22+
Lze jej najít na <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference>.
23+
24+
Často je však nejlepší použít obyčejné internetové vyhledávání. Do dotazu jednoduše napište „MDN [pojem]“, např. pro vyhledávání funkce `parseInt` zadejte <https://google.com/search?q=MDN+parseInt>.
2325

24-
Although, it's often best to use an internet search instead. Just use "MDN [term]" in the query, e.g. <https://google.com/search?q=MDN+parseInt> to search for `parseInt` function.
2526

27+
- **MSDN** – Manuál od Microsoftu s mnoha informacemi včetně těch o JavaScriptu (v IE se mu říká JScript). Potřebujete-li něco specifického ohledně Internet Exploreru, je lepší zavítat na: <http://msdn.microsoft.com/>.
2628

27-
- **MSDN** – Microsoft manual with a lot of information, including JavaScript (often referred to as JScript). If one needs something specific to Internet Explorer, better go there: <http://msdn.microsoft.com/>.
29+
Můžete také použít internetové vyhledávání s frázemi jako „RegExp MSDN“ nebo „RegExp MSDN jscript“.
2830

29-
Also, we can use an internet search with phrases such as "RegExp MSDN" or "RegExp MSDN jscript".
31+
## Tabulky kompatibility
3032

31-
## Compatibility tables
33+
JavaScript je neustále vyvíjen a pravidelně se do něj přidávají nové vlastnosti.
3234

33-
JavaScript is a developing language, new features get added regularly.
35+
Chcete-li vědět, v jakých enginech jsou tyto vlastnosti už podporovány, podívejte se na:
3436

35-
To see their support among browser-based and other engines, see:
37+
- <http://caniuse.com> - pro každou vlastnost obsahuje tabulku enginů, které ji podporují, např. chcete-li vidět, které enginy podporují moderní kryptografické funkce, jděte na <http://caniuse.com/#feat=cryptography>.
38+
- <https://kangax.github.io/compat-table> - tabulka vlastností jazyka a enginů, které je podporují nebo nepodporují.
3639

37-
- <http://caniuse.com> - per-feature tables of support, e.g. to see which engines support modern cryptography functions: <http://caniuse.com/#feat=cryptography>.
38-
- <https://kangax.github.io/compat-table> - a table with language features and engines that support those or don't support.
40+
Všechny tyto zdroje se vám budou při vývoji hodit, jelikož obsahují cenné informace o detailech jazyka, jejich podpoře apod.
3941

40-
All these resources are useful in real-life development, as they contain valuable information about language details, their support etc.
41-
42-
Please remember them (or this page) for the cases when you need in-depth information about a particular feature.
42+
Pamatujte si je (nebo tuto stránku) pro případ, že byste potřebovali podrobné informace o určité vlastnosti.

1-js/01-getting-started/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# An introduction
1+
# Úvod
22

3-
About the JavaScript language and the environment to develop with it.
3+
O jazyku JavaScript a jeho vývojovém prostředí.

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ We'll see more about working with numbers in the chapter <info:number>.
6666

6767
## BigInt
6868

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

7171
For most purposes that's quite enough, but sometimes we need really big numbers, e.g. for cryptography or microsecond-precision timestamps.
7272

@@ -81,10 +81,13 @@ const bigInt = 1234567890123456789012345678901234567890n;
8181

8282
As `BigInt` numbers are rarely needed, we don't cover them here, but devoted them a separate chapter <info:bigint>. Read it when you need such big numbers.
8383

84-
```smart header="Compatability issues"
85-
Right now `BigInt` is supported in Firefox/Chrome/Edge, but not in Safari/IE.
84+
85+
```smart header="Compatibility issues"
86+
Right now, `BigInt` is supported in Firefox/Chrome/Edge/Safari, but not in IE.
8687
```
8788

89+
You can check [*MDN* BigInt compatibility table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#Browser_compatibility) to know which versions of a browser are supported.
90+
8891
## String
8992

9093
A string in JavaScript must be surrounded by quotes.
@@ -127,7 +130,7 @@ We'll cover strings more thoroughly in the chapter <info:string>.
127130
```smart header="There is no *character* type."
128131
In some languages, there is a special "character" type for a single character. For example, in the C language and in Java it is called "char".
129132
130-
In JavaScript, there is no such type. There's only one type: `string`. A string may consist of only one character or many of them.
133+
In JavaScript, there is no such type. There's only one type: `string`. A string may consist of zero characters (be empty), one character or many of them.
131134
```
132135

133136
## Boolean (logical type)
@@ -255,7 +258,7 @@ The last three lines may need additional explanation:
255258

256259
There are 8 basic data types in JavaScript.
257260

258-
- `number` for numbers of any kind: integer or floating-point, integers are limited by ±2<sup>53</sup>.
261+
- `number` for numbers of any kind: integer or floating-point, integers are limited by <code>±(2<sup>53</sup>-1)</code>.
259262
- `bigint` is for integer numbers of arbitrary length.
260263
- `string` for strings. A string may have zero or more characters, there's no separate single-character type.
261264
- `boolean` for `true`/`false`.

1-js/02-first-steps/06-alert-prompt-confirm/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ As we'll be using the browser as our demo environment, let's see a couple of fun
44

55
## alert
66

7-
This one we've seen already. It shows a message and waits for the user to presses "OK".
7+
This one we've seen already. It shows a message and waits for the user to press "OK".
88

99
For example:
1010

@@ -31,7 +31,7 @@ It shows a modal window with a text message, an input field for the visitor, and
3131
: An optional second parameter, the initial value for the input field.
3232

3333
```smart header="The square brackets in syntax `[...]`"
34-
The square brackets around `default` in the syntax above denote that the parameter as optional, not required.
34+
The square brackets around `default` in the syntax above denote that the parameter is optional, not required.
3535
```
3636
3737
The visitor can type something in the prompt input field and press OK. Then we get that text in the `result`. Or they can cancel the input by pressing Cancel or hitting the `key:Esc` key, then we get `null` as the `result`.

1-js/02-first-steps/08-operators/4-fix-prompt/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let b = "2"; // prompt("Second number?", 2);
99
alert(a + b); // 12
1010
```
1111

12-
What we should to is to convert strings to numbers before `+`. For example, using `Number()` or prepending them with `+`.
12+
What we should do is to convert strings to numbers before `+`. For example, using `Number()` or prepending them with `+`.
1313

1414
For example, right before `prompt`:
1515

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Parentheses override any precedence, so if we're not satisfied with the default
180180
181181
There are many operators in JavaScript. Every operator has a corresponding precedence number. The one with the larger number executes first. If the precedence is the same, the execution order is from left to right.
182182
183-
Here's an extract from the [precedence table](https://developer.mozilla.org/en/JavaScript/Reference/operators/operator_precedence) (you don't need to remember this, but note that unary operators are higher than corresponding binary ones):
183+
Here's an extract from the [precedence table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence) (you don't need to remember this, but note that unary operators are higher than corresponding binary ones):
184184

185185
| Precedence | Name | Sign |
186186
|------------|------|------|
@@ -428,7 +428,7 @@ The list of operators:
428428
- RIGHT SHIFT ( `>>` )
429429
- ZERO-FILL RIGHT SHIFT ( `>>>` )
430430
431-
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/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators) article on MDN when a need arises.
431+
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.
432432

433433
## Comma
434434

1-js/02-first-steps/09-comparison/1-comparison-questions/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Some of the reasons:
1414

1515
1. Obviously, true.
1616
2. Dictionary comparison, hence false. `"a"` is smaller than `"p"`.
17-
3. Again, dictionary comparison, first char of `"2"` is greater than the first char of `"1"`.
17+
3. Again, dictionary comparison, first char `"2"` is greater than the first char `"1"`.
1818
4. Values `null` and `undefined` equal each other only.
1919
5. Strict equality is strict. Different types from both sides lead to false.
2020
6. Similar to `(4)`, `null` only equals `undefined`.

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ In JavaScript they are written like this:
66

77
- Greater/less than: <code>a &gt; b</code>, <code>a &lt; b</code>.
88
- Greater/less than or equals: <code>a &gt;= b</code>, <code>a &lt;= b</code>.
9-
- Equals: `a == b`, please note the double equality sign `=` means the equality test, while a single one `a = b` means an assignment.
9+
- Equals: `a == b`, please note the double equality sign `==` means the equality test, while a single one `a = b` means an assignment.
1010
- Not equals. In maths the notation is <code>&ne;</code>, but in JavaScript it's written as <code>a != b</code>.
1111

1212
In this article we'll learn more about different types of comparisons, how JavaScript makes them, including important peculiarities.
1313

14+
At the end you'll find a good recipe to avoid "JavaScript quirks"-related issues.
15+
1416
## Boolean is the result
1517

1618
All comparison operators return a boolean value:
@@ -55,7 +57,9 @@ The algorithm to compare two strings is simple:
5557
4. Repeat until the end of either string.
5658
5. If both strings end at the same length, then they are equal. Otherwise, the longer string is greater.
5759

58-
In the examples above, the comparison `'Z' > 'A'` gets to a result at the first step while the strings `"Glow"` and `"Glee"` are compared character-by-character:
60+
In the first example above, the comparison `'Z' > 'A'` gets to a result at the first step.
61+
62+
The second comparison `'Glow'` and `'Glee'` needs more steps as strings are compared character-by-character:
5963

6064
1. `G` is the same as `G`.
6165
2. `l` is the same as `l`.
@@ -196,13 +200,12 @@ We get these results because:
196200
- 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.
197201
- The equality check `(3)` returns `false` because `undefined` only equals `null`, `undefined`, and no other value.
198202

199-
### Evade problems
200-
201-
Why did we go over these examples? Should we remember these peculiarities all the time? Well, not really. Actually, these tricky things will gradually become familiar over time, but there's a solid way to evade problems with them:
203+
### Avoid problems
202204

203-
Just treat any comparison with `undefined/null` except the strict equality `===` with exceptional care.
205+
Why did we go over these examples? Should we remember these peculiarities all the time? Well, not really. Actually, these tricky things will gradually become familiar over time, but there's a solid way to avoid problems with them:
204206

205-
Don't use comparisons `>= > < <=` with a variable which may be `null/undefined`, unless you're really sure of what you're doing. If a variable can have these values, check for them separately.
207+
- Treat any comparison with `undefined/null` except the strict equality `===` with exceptional care.
208+
- Don't use comparisons `>= > < <=` with a variable which may be `null/undefined`, unless you're really sure of what you're doing. If a variable can have these values, check for them separately.
206209

207210
## Summary
208211

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Conditional operators: if, '?'
1+
# Conditional branching: if, '?'
22

33
Sometimes, we need to perform different actions based on different conditions.
44

0 commit comments

Comments
 (0)