Skip to content

Commit eed8f73

Browse files
authored
Merge pull request #139 from javascript-tutorial/sync-34a80e70
Sync with upstream @ 34a80e7
2 parents b90fa73 + c853ef2 commit eed8f73

50 files changed

Lines changed: 2066 additions & 228 deletions

File tree

Some content is hidden

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

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: iliakan

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,26 @@ let user = 'John'
9494
*!*var*/!* message = 'Hello';
9595
```
9696
97+
<<<<<<< HEAD
9798
Η λέξη-κλειδί `var` είναι * σχεδόν * ίδια με την `let`. Δηλώνει επίσης μια μεταβλητή, αλλά με έναν ελαφρώς διαφορετικό, "παλιό τρόπο".
9899
99100
Υπάρχουν λεπτές διαφορές μεταξύ της `let` και της `var`, αλλά δεν έχουν σημασία αυτή τη στιγμή. Θα τα καλύψουμε λεπτομερώς στο κεφάλαιο <info:var>.
101+
=======
102+
The `var` keyword is *almost* the same as `let`. It also declares a variable but in a slightly different, "old-school" way.
103+
104+
There are subtle differences between `let` and `var`, but they do not matter to us yet. We'll cover them in detail in the chapter <info:var>.
105+
>>>>>>> 34a80e70f8cce5794be259d25f815d7a7db7cbe3
100106
````
101107

102108
## Η αναλογία της πραγματικότητας
103109

104110
Μπορούμε εύκολα να κατανοήσουμε την έννοια μιας `μεταβλητής` αν τη φανταζόμαστε ως `κουτί` για δεδομένα, μια ετικέτα με μοναδικό όνομα.
105111

112+
<<<<<<< HEAD
106113
Για παράδειγμα, η μεταβλητή `message` μπορεί να φανταστεί ως ένα κουτί με την ένδειξη `message` με την τιμή `Hello!`:
114+
=======
115+
For instance, the variable `message` can be imagined as a box labelled `"message"` with the value `"Hello!"` in it:
116+
>>>>>>> 34a80e70f8cce5794be259d25f815d7a7db7cbe3
107117
108118
![](variable.svg)
109119

@@ -225,17 +235,26 @@ Variables named `apple` and `APPLE` are two different variables.
225235

226236
````smart header="Non-Latin letters are allowed, but not recommended"
227237
<<<<<<< HEAD
238+
<<<<<<< HEAD
228239
Είναι δυνατή η χρήση οποιασδήποτε γλώσσας, συμπεριλαμβανομένων κυριλλικών γραμμάτων ή ακόμη και ιερογλυφικών, όπως αυτή:
229240
=======
230241
It is possible to use any language, including cyrillic letters, Chinese logograms and so on, like this:
231242
>>>>>>> 5dff42ba283bce883428c383c080fa9392b71df8
243+
=======
244+
It is possible to use any language, including Cyrillic letters, Chinese logograms and so on, like this:
245+
>>>>>>> 34a80e70f8cce5794be259d25f815d7a7db7cbe3
232246
233247
```js
234248
let имя = '...';
235249
let 我 = '...';
236250
```
237251
252+
<<<<<<< HEAD
238253
Από τεχνικής άποψης, δεν υπάρχει σφάλμα εδώ, τέτοια ονόματα επιτρέπονται, αλλά υπάρχει μια διεθνής παράδοση για τη χρήση μεταβλητών ονόματων στα αγγλικά. Ακόμα κι αν γράφουμε ένα μικρό script, μπορεί να έχει μεγάλη διάρκεια ζωής. Άνθρωποι από άλλες χώρες μπορεί να χρειαστεί να το διαβάσουν κάποια στιγμή.
254+
=======
255+
Technically, there is no error here. Such names are allowed, but there is an international convention to use English in variable names. Even if we're writing a small script, it may have a long life ahead. People from other countries may need to read it sometime.
256+
````
257+
>>>>>>> 34a80e70f8cce5794be259d25f815d7a7db7cbe3
239258
240259
````warn header="Reserved names"
241260
Υπάρχει μια [λίστα δεσμευμένων λέξεων](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords), τα οποία δεν μπορούν να χρησιμοποιηθούν ως ονόματα μεταβλητών επειδή χρησιμοποιούνται από την ίδια τη γλώσσα.
@@ -289,16 +308,24 @@ const myBirthday = '18.04.1982';
289308
myBirthday = '01.01.2001'; // σφάλμα, δεν ξανα αναθέτουμε!
290309
```
291310
311+
<<<<<<< HEAD
292312
Όταν ένας προγραμματιστής είναι σίγουρος ότι μια μεταβλητή δεν θα αλλάξει ποτέ, μπορούν να την δηλώσουν με την `const` για να σιγουρευτούν και να κοινοποιήσουν το γεγονός σε όλους.
293313
294314
<<<<<<< HEAD
315+
=======
316+
When a programmer is sure that a variable will never change, they can declare it with `const` to guarantee and communicate that fact to everyone.
317+
>>>>>>> 34a80e70f8cce5794be259d25f815d7a7db7cbe3
295318
296319
### Σταθερές μεταβλητές με κεφαλαία
297320
=======
298321
### Uppercase constants
299322
>>>>>>> 30a5d5e2a7c3504c9afd5028f83f4a696e60aede
300323
324+
<<<<<<< HEAD
301325
Υπάρχει μια ευρέως διαδεδομένη πρακτική να χρησιμοποιείτε σταθερές ως ψευδώνυμα για τιμές που είναι δύσκολα στη απομνημονευση πριν από την εκτέλεση.
326+
=======
327+
There is a widespread practice to use constants as aliases for difficult-to-remember values that are known before execution.
328+
>>>>>>> 34a80e70f8cce5794be259d25f815d7a7db7cbe3
302329
303330
Αυτές τις μεταβλητές τις δηλώσουμε με κεφαλαία γράμματα και κάτω παύλες.
304331
@@ -323,7 +350,11 @@ alert(color); // #FF7F00
323350
324351
Πότε πρέπει να χρησιμοποιούμε κεφαλαία για μια σταθερά και πότε πρέπει να το ονομάσουμε κανονικά; Ας το ξεκαθαρίσουμε.
325352
353+
<<<<<<< HEAD
326354
Το να είσαι `constant` σημαίνει απλώς ότι η τιμή μιας μεταβλητής δεν αλλάζει ποτέ. Υπάρχουν όμως σταθερές που είναι γνωστές πριν από την εκτέλεση (όπως μια δεκαεξαδική τιμή για το κόκκινο) και υπάρχουν σταθερές που * υπολογίζονται * στο χρόνο εκτέλεσης, κατά τη διάρκεια της εκτέλεσης, αλλά δεν αλλάζουν μετά την αρχική τους ανάθεση.
355+
=======
356+
Being a "constant" just means that a variable's value never changes. But some constants are known before execution (like a hexadecimal value for red) and some constants are *calculated* in run-time, during the execution, but do not change after their initial assignment.
357+
>>>>>>> 34a80e70f8cce5794be259d25f815d7a7db7cbe3
327358
328359
<<<<<<< HEAD
329360
Για παραδείγμα:
@@ -335,7 +366,11 @@ For instance:
335366
const pageLoadTime = /* ο χρόνος που χρειάζεται για να φορτώση η σέλιδα */;
336367
```
337368
369+
<<<<<<< HEAD
338370
Η τιμή του "pageLoadTime" δεν είναι γνωστή πριν από τη φόρτωση της σελίδας, επομένως έχει κανονική ονομασία. Αλλά εξακολουθεί να είναι σταθερή επειδή δεν αλλάζει μετά την ανάθεση.
371+
=======
372+
The value of `pageLoadTime` is not known before the page load, so it's named normally. But it's still a constant because it doesn't change after the assignment.
373+
>>>>>>> 34a80e70f8cce5794be259d25f815d7a7db7cbe3
339374
340375
<<<<<<< HEAD
341376
Με άλλα λόγια, οι σταθερές με κεφαλαία ονομασία χρησιμοποιούνται μόνο ως ψευδώνυμα για "hard-coded" τιμές.
@@ -349,18 +384,31 @@ In other words, capital-named constants are only used as aliases for "hard-coded
349384
350385
Ένα όνομα μεταβλητής πρέπει να έχει καθαρό, με προφανές νόημα, που περιγράφει τα δεδομένα που αποθηκεύει.
351386
387+
<<<<<<< HEAD
352388
Η ονομασία μεταβλητών είναι μια από τις πιο σημαντικές και πολύπλοκες δεξιότητες στον προγραμματισμό. Μια γρήγορη ματιά στην ονομασία μεταβλητών μπορεί να αποκαλύψει ποιος κωδικός γράφτηκε από έναν αρχάριο έναντι ενός έμπειρου προγραμματιστή.
353389
354390
Σε ένα πραγματικό έργο, ο περισσότερος χρόνος αφιερώνεται τροποποιώντας και επεκτείνοντας μια υπάρχουσα βάση κώδικα και όχι γράφοντας κάτι εντελώς ξεχωριστό από το μηδέν. Όταν επιστρέψουμε σε κάποιον κώδικα αφού κάνουμε κάτι άλλο για λίγο, είναι πολύ πιο εύκολο να βρείτε πληροφορίες που έχουν καλή σήμανση. Ή, με άλλα λόγια, όταν οι μεταβλητές έχουν σωστή ονομασία.
391+
=======
392+
Variable naming is one of the most important and complex skills in programming. A glance at variable names can reveal which code was written by a beginner versus an experienced developer.
393+
394+
In a real project, most of the time is spent modifying and extending an existing code base rather than writing something completely separate from scratch. When we return to some code after doing something else for a while, it's much easier to find information that is well-labelled. Or, in other words, when the variables have good names.
395+
>>>>>>> 34a80e70f8cce5794be259d25f815d7a7db7cbe3
355396
356397
Αφιερώστε χρόνο για να σκεφτείτε το σωστό όνομα για μια μεταβλητή προτού την δηλώσετε. Κάτι τέτοιο θα σας αποζημιώσει πολύ.
357398
358399
Μερικοί κανόνες που πρέπει να ακολουθήσετε είναι:
359400
401+
<<<<<<< HEAD
360402
- Χρησιμοποιήστε ευκολά αναγνώσιμα ονόματα, όπως `userName` ή `shoppingCart`.
361403
- Μείνετε μακριά από συντομογραφίες ή σύντομα ονόματα όπως "a`," b "," c`, εκτός εάν γνωρίζετε πραγματικά τι κάνετε.
362404
- Κάντε ονόματα με μέγιστο περιγραφικό και συνοπτικό τρόπο. Παραδείγματα κακών ονομάτων είναι `δεδομένα` και `τιμή`. Τέτοια ονόματα δεν λένε τίποτα. Είναι να τα χρησιμοποιείτε σωστά, μόνο εάν το περιεχόμενο του κώδικα το καθιστά εξαιρετικά προφανές σε ποια δεδομένα ή αξία αναφέρεται η μεταβλητή.
363405
- Συμφωνείτε με όρους εντός της ομάδας σας και στο μυαλό σας. Εάν ένας επισκέπτης ιστότοπου ονομάζεται "χρήστης", θα πρέπει να ονομάσουμε σχετικές μεταβλητές "currentUser" ή "newUser" αντί για "currentVisitor" ή "newManInTown".
406+
=======
407+
- Use human-readable names like `userName` or `shoppingCart`.
408+
- Stay away from abbreviations or short names like `a`, `b`, and `c`, unless you know what you're doing.
409+
- Make names maximally descriptive and concise. Examples of bad names are `data` and `value`. Such names say nothing. It's only okay to use them if the context of the code makes it exceptionally obvious which data or value the variable is referencing.
410+
- Agree on terms within your team and in your mind. If a site visitor is called a "user" then we should name related variables `currentUser` or `newUser` instead of `currentVisitor` or `newManInTown`.
411+
>>>>>>> 34a80e70f8cce5794be259d25f815d7a7db7cbe3
364412
365413
Ακούγεται απλό; Πράγματι είναι, αλλά η δημιουργία περιγραφικών και συνοπτικών ονομασίων μεταβλητών στην πράξη δεν είναι. Κάντε το.
366414

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,18 @@ n = 12.345;
8383
const bigInt = 1234567890123456789012345678901234567890n;
8484
```
8585

86+
<<<<<<< HEAD
8687
```smart header="Compatability issues"
8788
Αυτήν τη στιγμή το "BigInt" υποστηρίζεται στον Firefox και το Chrome, αλλά όχι στο Safari/IE/Edge.
8889
8990
Καθώς οι αριθμοί `BigInt` σπάνια χρειάζονται, δεν τους καλύπτουμε εδώ, αλλά τους αφιερώσαμε ένα ξεχωριστό κεφάλαιο <info:bigint>. Διαβάστε το όταν χρειάζεστε τόσο μεγάλους αριθμούς.
9091
9192
## Συμβολοσειρά
93+
=======
94+
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.
95+
96+
## String
97+
>>>>>>> 34a80e70f8cce5794be259d25f815d7a7db7cbe3
9298
9399
Μια συμβολοσειρά σε JavaScript πρέπει να περιβάλλεται από εισαγωγικά.
94100

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Teams behind JavaScript engines have their own ideas about what to implement fir
77

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

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

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

@@ -73,7 +73,6 @@ JavaScript is a highly dynamic language. Scripts may add/modify any function, ev
7373
7474
Two interesting polyfill libraries are:
7575
- [core js](https://github.com/zloirock/core-js) that supports a lot, allows to include only needed features.
76-
- [polyfill.io](https://polyfill.io/) service that provides a script with polyfills, depending on the features and user's browser.
7776
7877
7978
## Summary
@@ -85,7 +84,7 @@ Just don't forget to use a transpiler (if using modern syntax or operators) and
8584
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.
8685
8786
Good resources that show the current state of support for various features:
88-
- <https://kangax.github.io/compat-table/es6/> - for pure JavaScript.
87+
- <https://compat-table.github.io/compat-table/es6/> - for pure JavaScript.
8988
- <https://caniuse.com/> - for browser-related functions.
9089
9190
P.S. Google Chrome is usually the most up-to-date with language features, try it if a tutorial demo fails. Most tutorial demos work with any modern browser though.

1-js/04-object-basics/04-object-methods/8-chain-calls/task.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ importance: 2
44

55
# Chaining
66

7-
There's a `ladder` object that allows to go up and down:
7+
There's a `ladder` object that allows you to go up and down:
88

99
```js
1010
let ladder = {
@@ -21,7 +21,7 @@ let ladder = {
2121
};
2222
```
2323

24-
Now, if we need to make several calls in sequence, can do it like this:
24+
Now, if we need to make several calls in sequence, we can do it like this:
2525

2626
```js
2727
ladder.up();
@@ -32,10 +32,10 @@ ladder.down();
3232
ladder.showStep(); // 0
3333
```
3434

35-
Modify the code of `up`, `down` and `showStep` to make the calls chainable, like this:
35+
Modify the code of `up`, `down`, and `showStep` to make the calls chainable, like this:
3636

3737
```js
3838
ladder.up().up().down().showStep().down().showStep(); // shows 1 then 0
3939
```
4040

41-
Such approach is widely used across JavaScript libraries.
41+
Such an approach is widely used across JavaScript libraries.

1-js/04-object-basics/09-object-toprimitive/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ let obj = {
253253
}
254254
};
255255

256-
alert(obj + 2); // 22 ("2" + 2), conversion to primitive returned a string => concatenation
256+
alert(obj + 2); // "22" ("2" + 2), conversion to primitive returned a string => concatenation
257257
```
258258

259259
## Summary

0 commit comments

Comments
 (0)