Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 265b43e

Browse files
authoredJan 25, 2021
Merge pull request #20 from javascript-tutorial/sync-97ef8624
Sync with upstream @ 97ef862
2 parents 0932f46 + cacc81c commit 265b43e

File tree

33 files changed

+239
-191
lines changed

33 files changed

+239
-191
lines changed
 

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ Néhány példa:
111111
- [Flow](http://flow.org/): szintén a szigorúbb típusosságot valósítja meg, de a TypeScripttől eltérő módon. A Facebook fejlesztése.
112112
- [Dart](https://www.dartlang.org/): önálló nyelv, saját, böngészőn kívüli motorral. JavaScriptté alakítható. A Google fejlesztése.
113113
- [Brython](https://brython.info/) is a Python transpiler to JavaScript that enables the writing of applications in pure Python without JavaScript.
114+
<<<<<<< HEAD
114115
- [Kotlin](https://kotlinlang.org/docs/js-overview.html): egy modern, tömör, biztonságos programozási nyelv, amellyel böngésző és Node alá is fejleszthetünk .
116+
=======
117+
- [Kotlin](https://kotlinlang.org/docs/reference/js-overview.html) is a modern, concise and safe programming language that can target the browser or Node.
118+
>>>>>>> 97ef86242f9f236b13152e1baf52a55c4db8728a
115119
116120
A fentieken túl számos más JavaScripten alapuló nyelv létezik. Még akkor is, ha egy JavaScriptté alakítandó nyelvvel dolgozunk, mindenképpen érdemes alaposan ismerni a JavaScriptet, hogy valóban értsük, hogyan működik a programunk.
117121

‎1-js/01-getting-started/2-manuals-specifications/article.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,32 @@ Minden évben új ECMAScript verzió jelenik meg. A soronkövetkező verzió akt
1313

1414
A legújabb nyelvi lehetőségekről és a szabványossá válás előtt álló, úgynevezett 3-as szintű előterjesztésekről a <https://github.com/tc39/proposals> oldalon tájékozódhatunk.
1515

16+
<<<<<<< HEAD
1617
Böngészoldali programok írásához további specifikációkkal ismerkedhetünk meg a [második részben](info:browser-environment).
18+
=======
19+
Also, if you're in developing for the browser, then there are other specifications covered in the [second part](info:browser-environment) of the tutorial.
20+
>>>>>>> 97ef86242f9f236b13152e1baf52a55c4db8728a
1721
1822
## Leírások
1923

24+
<<<<<<< HEAD
2025
- A **Mozilla Developer Network (MDN) JavaScript Referencia** egy mélyreható, széleskörű, példákkal illusztrált leírás a nyelv működéséről, a nyelvi elemekről, a beépített függvényekről és a böngészőben elérhető egyéb technológiákról.
26+
=======
27+
- **MDN (Mozilla) JavaScript Reference** is the main manual with examples and other information. It's great to get in-depth information about individual language functions, methods etc.
28+
>>>>>>> 97ef86242f9f236b13152e1baf52a55c4db8728a
2129
2230
A referencia a <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference> oldalon található.
2331

32+
<<<<<<< HEAD
2433
Az MDN közvetlen böngészése helyett az esetek többségében célszerűbb egy "MDN [kulcsszó]" alakú keresést indítani, például, ha a `parseInt` függvényről akarunk olvasni: <https://google.com/search?q=MDN+parseInt>.
2534

2635

2736
- **MSDN** – A Microsoft technikai dokumentáció gyűjteménye. Egyebek mellett JavaScript leírások is találhatóak rajta (többnyire JScript megnevezéssel). Internet Explorerrel kapcsolatos kérdések esetén a legjobb forrás. <http://msdn.microsoft.com/>.
2837

2938
Az MDN-hez hasonlóan, itt is hatékonyabban kereshetünk közvetetten, például "RegExp MSDN" vagy "RegExp MSDN jscript".
39+
=======
40+
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.
41+
>>>>>>> 97ef86242f9f236b13152e1baf52a55c4db8728a
3042
3143
## Kompatibilitási táblázatok
3244

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Here's a more complex example:
104104
alert(2 + 2 + '1' ); // "41" and not "221"
105105
```
106106
107-
Here, operators work one after another. The first `+` sums two numbers, so it returns `4`, then the next `+` adds the string `1` to it, so it's like `4 + '1' = 41`.
107+
Here, operators work one after another. The first `+` sums two numbers, so it returns `4`, then the next `+` adds the string `1` to it, so it's like `4 + '1' = '41'`.
108108

109109
```js run
110110
alert('1' + 2 + 2); // "122" and not "14"
@@ -219,7 +219,7 @@ alert( x ); // 5
219219
220220
The fact of `=` being an operator, not a "magical" language construct has an interesting implication.
221221
222-
Most operators in JavaScript return a value. That's obvious for `+` and `-`, but also true for `=`.
222+
All operators in JavaScript return a value. That's obvious for `+` and `-`, but also true for `=`.
223223

224224
The call `x = value` writes the `value` into `x` *and then returns it*.
225225

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ switch (a) {
4747
break;
4848
*/!*
4949
case 5:
50-
alert( 'Too large' );
50+
alert( 'Too big' );
5151
break;
5252
default:
5353
alert( "I don't know such values" );

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ We covered three ways to create a function in JavaScript:
273273
```
274274
275275
276-
- Functions may have local variables: those declared inside its body. Such variables are only visible inside the function.
276+
- Functions may have local variables: those declared inside its body or its parameter list. Such variables are only visible inside the function.
277277
- Parameters can have default values: `function sum(a = 1, b = 2) {...}`.
278278
- Functions always return something. If there's no `return` statement, then the result is `undefined`.
279279

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ There are buttons for it at the top of the right panel. Let's engage them.
135135
Clicking this again and again will step through all script statements one by one.
136136

137137
<span class="devtools" style="background-position:-62px -192px"></span> -- "Step over": run the next command, but *don't go into a function*, hotkey `key:F10`.
138-
: Similar to the previous the "Step" command, but behaves differently if the next statement is a function call. That is: not a built-in, like `alert`, but a function of our own.
138+
: Similar to the previous "Step" command, but behaves differently if the next statement is a function call. That is: not a built-in, like `alert`, but a function of our own.
139139

140140
The "Step" command goes into it and pauses the execution at its first line, while "Step over" executes the nested function call invisibly, skipping the function internals.
141141

‎1-js/03-code-quality/02-coding-style/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ There are two types of indents:
116116
117117
One advantage of spaces over tabs is that spaces allow more flexible configurations of indents than the tab symbol.
118118
119-
For instance, we can align the arguments with the opening bracket, like this:
119+
For instance, we can align the parameters with the opening bracket, like this:
120120
121121
```js no-beautify
122122
show(parameters,

‎1-js/03-code-quality/02-coding-style/code-style.svg

Lines changed: 1 addition & 1 deletion
Loading

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A good page to see the current state of support for language features is <https:
1111

1212
As programmers, we'd like to use most recent features. The more good stuff - the better!
1313

14-
From the other hand, how to make out modern code work on older engines that don't understand recent features yet?
14+
On the other hand, how to make our modern code work on older engines that don't understand recent features yet?
1515

1616
There are two tools for that:
1717

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Simply put, "reachable" values are those that are accessible or usable somehow.
1414

1515
For instance:
1616

17-
- Local variables and parameters of the current function.
18-
- Variables and parameters for other functions on the current chain of nested calls.
17+
- The currently executing function, its local variables and parameters.
18+
- Other functions on the current chain of nested calls, their local variables and parameters.
1919
- Global variables.
2020
- (there are some other, internal ones as well)
2121

‎1-js/04-object-basics/04-object-methods/7-calculator/_js.view/test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ describe("calculator", function() {
1515
afterEach(function() {
1616
prompt.restore();
1717
});
18+
19+
it('the read get two values and saves them as object properties', function () {
20+
assert.equal(calculator.a, 2);
21+
assert.equal(calculator.b, 3);
22+
});
1823

1924
it("the sum is 5", function() {
2025
assert.equal(calculator.sum(), 5);

‎1-js/04-object-basics/06-constructor-new/2-calculator-constructor/_js.view/test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ describe("calculator", function() {
1010
calculator = new Calculator();
1111
calculator.read();
1212
});
13+
14+
it("the read method asks for two values using prompt and remembers them in object properties", function() {
15+
assert.equal(calculator.a, 2);
16+
assert.equal(calculator.b, 3);
17+
});
1318

1419
it("when 2 and 3 are entered, the sum is 5", function() {
1520
assert.equal(calculator.sum(), 5);

‎1-js/04-object-basics/06-constructor-new/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ The syntax from this section is rarely used, skip it unless you want to know eve
9191

9292
Inside a function, we can check whether it was called with `new` or without it, using a special `new.target` property.
9393

94-
It is empty for regular calls and equals the function if called with `new`:
94+
It is undefined for regular calls and equals the function if called with `new`:
9595

9696
```js run
9797
function User() {

‎1-js/04-object-basics/07-optional-chaining/article.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ That's why the optional chaining `?.` was added to the language. To solve this p
7474

7575
## Optional chaining
7676

77-
The optional chaining `?.` stops the evaluation if the part before `?.` is `undefined` or `null` and returns that part.
77+
The optional chaining `?.` stops the evaluation if the value before `?.` is `undefined` or `null` and returns `undefined`.
7878

7979
**Further in this article, for brevity, we'll be saying that something "exists" if it's not `null` and not `undefined`.**
8080

8181
In other words, `value?.prop`:
82-
- is the same as `value.prop` if `value` exists,
82+
- works as `value.prop`, if `value` exists,
8383
- otherwise (when `value` is `undefined/null`) it returns `undefined`.
8484

8585
Here's the safe way to access `user.address.street` using `?.`:
@@ -103,7 +103,7 @@ alert( user?.address.street ); // undefined
103103
104104
Please note: the `?.` syntax makes optional the value before it, but not any further.
105105
106-
E.g. in `user?.address.street.name` the `?.` allows `user` to be `null/undefined`, but it's all it does. Further properties are accessed in a regular way. If we want some of them to be optional, then we'll need to replace more `.` with `?.`.
106+
E.g. in `user?.address.street.name` the `?.` allows `user` to safely be `null/undefined` (and returns `undefined` in that case), but that's only for `user`. Further properties are accessed in a regular way. If we want some of them to be optional, then we'll need to replace more `.` with `?.`.
107107
108108
```warn header="Don't overuse the optional chaining"
109109
We should use `?.` only where it's ok that something doesn't exist.
@@ -173,18 +173,16 @@ Then `?.()` checks the left part: if the admin function exists, then it runs (th
173173
The `?.[]` syntax also works, if we'd like to use brackets `[]` to access properties instead of dot `.`. Similar to previous cases, it allows to safely read a property from an object that may not exist.
174174
175175
```js run
176+
let key = "firstName";
177+
176178
let user1 = {
177179
firstName: "John"
178180
};
179181

180-
let user2 = null; // Imagine, we couldn't authorize the user
181-
182-
let key = "firstName";
182+
let user2 = null;
183183

184184
alert( user1?.[key] ); // John
185185
alert( user2?.[key] ); // undefined
186-
187-
alert( user1?.[key]?.something?.not?.existing); // undefined
188186
```
189187
190188
Also we can use `?.` with `delete`:

‎1-js/04-object-basics/08-symbol/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ There will be no conflict between our and their identifiers, because symbols are
109109

110110
...But if we used a string `"id"` instead of a symbol for the same purpose, then there *would* be a conflict:
111111

112-
```js run
112+
```js
113113
let user = { name: "John" };
114114

115115
// Our script uses "id" property

‎1-js/05-data-types/02-number/article.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,29 @@ Imagine we need to write 1 billion. The obvious way is:
1616
let billion = 1000000000;
1717
```
1818

19-
But in real life, we usually avoid writing a long string of zeroes as it's easy to mistype. Also, we are lazy. We will usually write something like `"1bn"` for a billion or `"7.3bn"` for 7 billion 300 million. The same is true for most large numbers.
19+
We also can use underscore `_` as the separator:
2020

21-
In JavaScript, we shorten a number by appending the letter `"e"` to the number and specifying the zeroes count:
21+
```js
22+
let billion = 1_000_000_000;
23+
```
24+
25+
Here the underscore `_` plays the role of the "syntactic sugar", it makes the number more readable. The JavaScript engine simply ignores `_` between digits, so it's exactly the same one billion as above.
26+
27+
In real life though, we try to avoid writing long sequences of zeroes. We're too lazy for that. We'll try to write something like `"1bn"` for a billion or `"7.3bn"` for 7 billion 300 million. The same is true for most large numbers.
28+
29+
In JavaScript, we can shorten a number by appending the letter `"e"` to it and specifying the zeroes count:
2230

2331
```js run
2432
let billion = 1e9; // 1 billion, literally: 1 and 9 zeroes
2533

26-
alert( 7.3e9 ); // 7.3 billions (7,300,000,000)
34+
alert( 7.3e9 ); // 7.3 billions (same as 7300000000 or 7_300_000_000)
2735
```
2836

29-
In other words, `"e"` multiplies the number by `1` with the given zeroes count.
37+
In other words, `e` multiplies the number by `1` with the given zeroes count.
3038

3139
```js
32-
1e3 = 1 * 1000
33-
1.23e6 = 1.23 * 1000000
40+
1e3 = 1 * 1000 // e3 means *1000
41+
1.23e6 = 1.23 * 1000000 // e6 means *1000000
3442
```
3543

3644
Now let's write something very small. Say, 1 microsecond (one millionth of a second):
@@ -125,7 +133,7 @@ There are several built-in functions for rounding:
125133
: Rounds up: `3.1` becomes `4`, and `-1.1` becomes `-1`.
126134

127135
`Math.round`
128-
: Rounds to the nearest integer: `3.1` becomes `3`, `3.6` becomes `4` and `-1.1` becomes `-1`.
136+
: Rounds to the nearest integer: `3.1` becomes `3`, `3.6` becomes `4`, the middle case: `3.5` rounds up to `4` too.
129137

130138
`Math.trunc` (not supported by Internet Explorer)
131139
: Removes anything after the decimal point without rounding: `3.1` becomes `3`, `-1.1` becomes `-1`.

‎1-js/05-data-types/04-array/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ This operator has no special treatment for arrays, it works with them as with an
438438
Let's recall the rules:
439439

440440
- Two objects are equal `==` only if they're references to the same object.
441-
- If one of arguments of `==` is an object, and the other one is a primitive, then the object gets converted to primitive, as explained in the chapter <info:object-toprimitive>.
441+
- If one of the arguments of `==` is an object, and the other one is a primitive, then the object gets converted to primitive, as explained in the chapter <info:object-toprimitive>.
442442
- ...With an exception of `null` and `undefined` that equal `==` each other and nothing else.
443443

444444
The strict comparison `===` is even simpler, as it doesn't convert types.
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
function topSalary(salaries) {
22

3-
let max = 0;
3+
let maxSalary = 0;
44
let maxName = null;
55

66
for(const [name, salary] of Object.entries(salaries)) {
77
if (max < salary) {
8-
max = salary;
8+
maxSalary = salary;
99
maxName = name;
1010
}
1111
}
1212

1313
return maxName;
14-
}
15-
16-
14+
}

0 commit comments

Comments
 (0)
Please sign in to comment.