Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
7a7b25a
small rephrasings
RapTho Dec 14, 2020
dfa5ec9
small reformulation
RapTho Dec 14, 2020
0427ecb
Reformulations
RapTho Dec 17, 2020
b9481da
Edits based on feedback iliakan
RapTho Jan 2, 2021
bcbb5d5
Edit based on feedback iliakan
RapTho Jan 2, 2021
03b6d86
Edit based on feedback iliakan
RapTho Jan 2, 2021
16ac397
kotlin 404
joaquinelio Jan 4, 2021
e730c5a
Merge pull request #2416 from joaquinelio/patch-1
iliakan Jan 4, 2021
c67f8b8
Merge pull request #2388 from RapTho/patch-4
iliakan Jan 4, 2021
51f3915
Merge pull request #2390 from RapTho/patch-5
iliakan Jan 4, 2021
42ee148
Merge pull request #2395 from RapTho/patch-8
iliakan Jan 4, 2021
c350514
minor
iliakan Jan 7, 2021
32518b7
minor
iliakan Jan 7, 2021
80c4901
all operators must return a value
lumosmind Jan 7, 2021
a2561dc
Minor output typo
TaylorClay Jan 7, 2021
2229a48
Update article.md
martynov-94 Jan 8, 2021
5965ae7
Update currying function to use bind instead of wrapper pass
lakbychance Jan 9, 2021
997f392
Add the (2) point reference
lakbychance Jan 9, 2021
3b7d493
closes #2421
iliakan Jan 9, 2021
18a60ab
Merge pull request #2420 from martynov-94/patch-1
iliakan Jan 9, 2021
930485b
Merge pull request #2419 from TaylorClay/patch-1
iliakan Jan 9, 2021
12b23c7
Merge pull request #2417 from lumosmind/patch-55
iliakan Jan 9, 2021
6113f33
Merge pull request #2422 from lapstjup/patch-1
iliakan Jan 9, 2021
2027939
minor fixes
iliakan Jan 9, 2021
6a432df
parameters are also local variables
lumosmind Jan 9, 2021
86a6021
minor fixes
iliakan Jan 10, 2021
468e355
Merge pull request #2423 from lumosmind/patch-56
iliakan Jan 10, 2021
6b296c1
new.target is undefined not empty
sarscoder Jan 11, 2021
b9d5335
Merge pull request #2425 from sarscode/sarscode-constructor-new-target
iliakan Jan 11, 2021
afd41ea
each unit parts must be tested
lumosmind Jan 12, 2021
eb3b360
minor fixes
iliakan Jan 12, 2021
a27b7e2
"exception" vs "new feature" ?
joaquinelio Jan 12, 2021
73fd173
Update article.md
bilalbutt044 Jan 12, 2021
09f8ca8
individual test case for methods
lumosmind Jan 12, 2021
85fe7b8
no need to "js run"
lumosmind Jan 13, 2021
09ec05c
minor fixes
iliakan Jan 13, 2021
3c673ac
Merge pull request #2434 from lumosmind/patch-65
iliakan Jan 13, 2021
c7d3072
closes #2433
iliakan Jan 13, 2021
58e6456
minor fixes
iliakan Jan 13, 2021
003d602
Merge pull request #2432 from lumosmind/patch-62
iliakan Jan 13, 2021
9c1a0fd
Merge pull request #2431 from bilalbutt044/patch-1
iliakan Jan 13, 2021
f6d3e30
Merge pull request #2429 from lumosmind/patch-61
iliakan Jan 13, 2021
bc8b37b
minor fixes
iliakan Jan 13, 2021
4307531
Merge branch 'master' of github.com:javascript-tutorial/en.javascript…
iliakan Jan 13, 2021
15e6f2d
minor fixes
iliakan Jan 13, 2021
e95ca4b
typo
lumosmind Jan 13, 2021
9c082c8
minor fixes
iliakan Jan 13, 2021
99b2a09
Merge pull request #2437 from lumosmind/patch-68
iliakan Jan 13, 2021
8eb6f97
minor fixes
iliakan Jan 13, 2021
f797858
closes #2398
iliakan Jan 14, 2021
3a0b3f4
Merge pull request #2430 from joaquinelio/patch-1
iliakan Jan 16, 2021
9e1d531
Fix mismatched alert text
emek Jan 16, 2021
37c906c
fix typo
msisaifu Jan 17, 2021
0f65c39
the type name is lookbehind instead of lookahead
msisaifu Jan 17, 2021
bdb19f6
too wordy explanation
joaquinelio Jan 17, 2021
04e2514
Update article.md
redrambles Jan 20, 2021
0deca2c
typo
martynov-94 Jan 21, 2021
6451000
Spelling error & wrong idiom
bierlingm Jan 21, 2021
ab7b646
Merge pull request #2453 from bierlingm/patch-1
iliakan Jan 21, 2021
acf62b0
minor fixes
iliakan Jan 21, 2021
6e326fb
Merge pull request #2449 from redrambles/patch-2
iliakan Jan 21, 2021
29827e8
Merge pull request #2447 from joaquinelio/patch-1
iliakan Jan 21, 2021
0c4913c
minor fixes
iliakan Jan 21, 2021
354c633
Merge pull request #2445 from msisaifu/fix-typo
iliakan Jan 21, 2021
b462bdd
Merge pull request #2443 from emek/minor-text-fix
iliakan Jan 21, 2021
21a751a
to both -> both to
martynov-94 Jan 22, 2021
f0d389e
Merge pull request #2457 from martynov-94/patch-3
iliakan Jan 22, 2021
7bd55a4
Merge pull request #2458 from martynov-94/patch-2
iliakan Jan 22, 2021
13a6a75
modify alternative method in comment of mixins' code example
AmosChenYQ Jan 23, 2021
97ef862
Merge pull request #2462 from AmosChenYQ/amoschen-classes-correct
iliakan Jan 23, 2021
cacc81c
merging all conflicts
iliakan Jan 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions 1-js/01-getting-started/1-intro/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ Néhány példa:
- [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.
- [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.
- [Brython](https://brython.info/) is a Python transpiler to JavaScript that enables the writing of applications in pure Python without JavaScript.
<<<<<<< HEAD
- [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 .
=======
- [Kotlin](https://kotlinlang.org/docs/reference/js-overview.html) is a modern, concise and safe programming language that can target the browser or Node.
>>>>>>> 97ef86242f9f236b13152e1baf52a55c4db8728a

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.

Expand Down
12 changes: 12 additions & 0 deletions 1-js/01-getting-started/2-manuals-specifications/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,32 @@ Minden évben új ECMAScript verzió jelenik meg. A soronkövetkező verzió akt

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.

<<<<<<< HEAD
Böngészoldali programok írásához további specifikációkkal ismerkedhetünk meg a [második részben](info:browser-environment).
=======
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.
>>>>>>> 97ef86242f9f236b13152e1baf52a55c4db8728a

## Leírások

<<<<<<< HEAD
- 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.
=======
- **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.
>>>>>>> 97ef86242f9f236b13152e1baf52a55c4db8728a

A referencia a <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference> oldalon található.

<<<<<<< HEAD
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>.


- **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/>.

Az MDN-hez hasonlóan, itt is hatékonyabban kereshetünk közvetetten, például "RegExp MSDN" vagy "RegExp MSDN jscript".
=======
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.
>>>>>>> 97ef86242f9f236b13152e1baf52a55c4db8728a

## Kompatibilitási táblázatok

Expand Down
4 changes: 2 additions & 2 deletions 1-js/02-first-steps/08-operators/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Here's a more complex example:
alert(2 + 2 + '1' ); // "41" and not "221"
```

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`.
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'`.

```js run
alert('1' + 2 + 2); // "122" and not "14"
Expand Down Expand Up @@ -219,7 +219,7 @@ alert( x ); // 5

The fact of `=` being an operator, not a "magical" language construct has an interesting implication.

Most operators in JavaScript return a value. That's obvious for `+` and `-`, but also true for `=`.
All operators in JavaScript return a value. That's obvious for `+` and `-`, but also true for `=`.

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

Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/14-switch/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ switch (a) {
break;
*/!*
case 5:
alert( 'Too large' );
alert( 'Too big' );
break;
default:
alert( "I don't know such values" );
Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/18-javascript-specials/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ We covered three ways to create a function in JavaScript:
```


- Functions may have local variables: those declared inside its body. Such variables are only visible inside the function.
- Functions may have local variables: those declared inside its body or its parameter list. Such variables are only visible inside the function.
- Parameters can have default values: `function sum(a = 1, b = 2) {...}`.
- Functions always return something. If there's no `return` statement, then the result is `undefined`.

Expand Down
2 changes: 1 addition & 1 deletion 1-js/03-code-quality/01-debugging-chrome/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ There are buttons for it at the top of the right panel. Let's engage them.
Clicking this again and again will step through all script statements one by one.

<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`.
: 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.
: 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.

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.

Expand Down
2 changes: 1 addition & 1 deletion 1-js/03-code-quality/02-coding-style/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ There are two types of indents:

One advantage of spaces over tabs is that spaces allow more flexible configurations of indents than the tab symbol.

For instance, we can align the arguments with the opening bracket, like this:
For instance, we can align the parameters with the opening bracket, like this:

```js no-beautify
show(parameters,
Expand Down
2 changes: 1 addition & 1 deletion 1-js/03-code-quality/02-coding-style/code-style.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion 1-js/03-code-quality/06-polyfills/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A good page to see the current state of support for language features is <https:

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

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

There are two tools for that:

Expand Down
4 changes: 2 additions & 2 deletions 1-js/04-object-basics/03-garbage-collection/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Simply put, "reachable" values are those that are accessible or usable somehow.

For instance:

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ describe("calculator", function() {
afterEach(function() {
prompt.restore();
});

it('the read get two values and saves them as object properties', function () {
assert.equal(calculator.a, 2);
assert.equal(calculator.b, 3);
});

it("the sum is 5", function() {
assert.equal(calculator.sum(), 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ describe("calculator", function() {
calculator = new Calculator();
calculator.read();
});

it("the read method asks for two values using prompt and remembers them in object properties", function() {
assert.equal(calculator.a, 2);
assert.equal(calculator.b, 3);
});

it("when 2 and 3 are entered, the sum is 5", function() {
assert.equal(calculator.sum(), 5);
Expand Down
2 changes: 1 addition & 1 deletion 1-js/04-object-basics/06-constructor-new/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ The syntax from this section is rarely used, skip it unless you want to know eve

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

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

```js run
function User() {
Expand Down
14 changes: 6 additions & 8 deletions 1-js/04-object-basics/07-optional-chaining/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ That's why the optional chaining `?.` was added to the language. To solve this p

## Optional chaining

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

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

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

Here's the safe way to access `user.address.street` using `?.`:
Expand All @@ -103,7 +103,7 @@ alert( user?.address.street ); // undefined

Please note: the `?.` syntax makes optional the value before it, but not any further.

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 `?.`.
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 `?.`.

```warn header="Don't overuse the optional chaining"
We should use `?.` only where it's ok that something doesn't exist.
Expand Down Expand Up @@ -173,18 +173,16 @@ Then `?.()` checks the left part: if the admin function exists, then it runs (th
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.

```js run
let key = "firstName";

let user1 = {
firstName: "John"
};

let user2 = null; // Imagine, we couldn't authorize the user

let key = "firstName";
let user2 = null;

alert( user1?.[key] ); // John
alert( user2?.[key] ); // undefined

alert( user1?.[key]?.something?.not?.existing); // undefined
```

Also we can use `?.` with `delete`:
Expand Down
2 changes: 1 addition & 1 deletion 1-js/04-object-basics/08-symbol/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ There will be no conflict between our and their identifiers, because symbols are

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

```js run
```js
let user = { name: "John" };

// Our script uses "id" property
Expand Down
22 changes: 15 additions & 7 deletions 1-js/05-data-types/02-number/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,29 @@ Imagine we need to write 1 billion. The obvious way is:
let billion = 1000000000;
```

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.
We also can use underscore `_` as the separator:

In JavaScript, we shorten a number by appending the letter `"e"` to the number and specifying the zeroes count:
```js
let billion = 1_000_000_000;
```

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.

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.

In JavaScript, we can shorten a number by appending the letter `"e"` to it and specifying the zeroes count:

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

alert( 7.3e9 ); // 7.3 billions (7,300,000,000)
alert( 7.3e9 ); // 7.3 billions (same as 7300000000 or 7_300_000_000)
```

In other words, `"e"` multiplies the number by `1` with the given zeroes count.
In other words, `e` multiplies the number by `1` with the given zeroes count.

```js
1e3 = 1 * 1000
1.23e6 = 1.23 * 1000000
1e3 = 1 * 1000 // e3 means *1000
1.23e6 = 1.23 * 1000000 // e6 means *1000000
```

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

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

`Math.trunc` (not supported by Internet Explorer)
: Removes anything after the decimal point without rounding: `3.1` becomes `3`, `-1.1` becomes `-1`.
Expand Down
2 changes: 1 addition & 1 deletion 1-js/05-data-types/04-array/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ This operator has no special treatment for arrays, it works with them as with an
Let's recall the rules:

- Two objects are equal `==` only if they're references to the same object.
- 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>.
- 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>.
- ...With an exception of `null` and `undefined` that equal `==` each other and nothing else.

The strict comparison `===` is even simpler, as it doesn't convert types.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
function topSalary(salaries) {

let max = 0;
let maxSalary = 0;
let maxName = null;

for(const [name, salary] of Object.entries(salaries)) {
if (max < salary) {
max = salary;
maxSalary = salary;
maxName = name;
}
}

return maxName;
}


}
Loading