Skip to content

Commit a4101ca

Browse files
authored
Merge pull request #96 from javascript-tutorial/sync-206485fc
Sync with upstream @ 206485f
2 parents faaa8f1 + b3ff007 commit a4101ca

29 files changed

Lines changed: 73 additions & 46 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ let my-name; // παύλες '-' απαγορεύονται
194194
```
195195

196196
```smart header="Case matters"
197+
<<<<<<< HEAD
197198
Μεταβλητές `apple` και `AppLE` είναι δύο διαφορετικές μεταβλητές.
199+
=======
200+
Variables named `apple` and `APPLE` are two different variables.
201+
>>>>>>> 206485fc3a5465f961608b6e7303fae2e1a0e0b5
198202
```
199203

200204
````smart header="Non-Latin letters are allowed, but not recommended"
@@ -298,7 +302,11 @@ const pageLoadTime = /* ο χρόνος που χρειάζεται για να
298302
299303
Η τιμή του "pageLoadTime" δεν είναι γνωστή πριν από τη φόρτωση της σελίδας, επομένως έχει κανονική ονομασία. Αλλά εξακολουθεί να είναι σταθερή επειδή δεν αλλάζει μετά την ανάθεση.
300304
305+
<<<<<<< HEAD
301306
Με άλλα λόγια, οι σταθερές με κεφαλαία ονομασία χρησιμοποιούνται μόνο ως ψευδώνυμα για "hard-coded" τιμές.
307+
=======
308+
In other words, capital-named constants are only used as aliases for "hard-coded" values.
309+
>>>>>>> 206485fc3a5465f961608b6e7303fae2e1a0e0b5
302310
303311
## Να λεμε τα πράγματα με το ονομά τους
304312

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,11 @@ for (let i = 0; i < 10; i++) {
263263

264264
Από τεχνική άποψη, αυτό είναι πανομοιότυπο με το παραπάνω παράδειγμα. Σίγουρα, μπορούμε απλώς να τυλίξουμε τον κώδικα σε ένα μπλοκ `if` αντί να χρησιμοποιήσουμε το `continue`.
265265

266+
<<<<<<< HEAD
266267
Αλλά ως παρενέργεια, αυτό δημιούργησε ένα ακόμη επίπεδο ένθεσης (η κλήση `alert` μέσα στα άγκυστρα). Εάν ο κώδικας στο εσωτερικό του `if` είναι μεγαλύτερος από μερικές γραμμές, αυτό μπορεί να μειώσει τη συνολική αναγνωσιμότητα.
268+
=======
269+
But as a side effect, this created one more level of nesting (the `alert` call inside the curly braces). If the code inside of `if` is longer than a few lines, that may decrease the overall readability.
270+
>>>>>>> 206485fc3a5465f961608b6e7303fae2e1a0e0b5
267271
````
268272
269273
````warn header="Δεν υπάρχει `break/continue` στη δεξιά πλευρά του '?'"

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ switch (a) {
139139
140140
Τώρα και τα δύο `3` και `5` εμφανίζουν το ίδιο μήνυμα.
141141
142+
<<<<<<< HEAD
142143
Η ικανότητα "ομαδοποίησης" περιπτώσεων είναι μια παρενέργεια του τρόπου λειτουργίας του `switch/case` χωρίς το `break`. Εδώ η εκτέλεση του `case 3` ξεκινά από τη γραμμή `(*)` και περνάει από το `case 5`, επειδή δεν υπάρχει `break`.
144+
=======
145+
The ability to "group" cases is a side effect of how `switch/case` works without `break`. Here the execution of `case 3` starts from the line `(*)` and goes through `case 5`, because there's no `break`.
146+
>>>>>>> 206485fc3a5465f961608b6e7303fae2e1a0e0b5
143147
144148
## Η σημασία του τύπου
145149

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,11 @@ function name(parameters, delimited, by, comma) {
470470
471471
Για να κάνετε τον κώδικα καθαρό και κατανοητό, συνίσταται η χρήση κυρίως τοπικών μεταβλητών και παραμέτρων στη συνάρτηση, όχι εξωτερικών μεταβλητών.
472472
473+
<<<<<<< HEAD
473474
Είναι πάντα πιο εύκολο να κατανοήσουμε μια συνάρτηση που παίρνει παραμέτρους, δουλεύει μαζί τους και επιστρέφει ένα αποτέλεσμα, παρά μια συνάρτηση που δεν έχει παραμέτρους, αλλά τροποποιεί τις εξωτερικές μεταβλητές ως side-effect.
475+
=======
476+
It is always easier to understand a function which gets parameters, works with them and returns a result than a function which gets no parameters, but modifies outer variables as a side effect.
477+
>>>>>>> 206485fc3a5465f961608b6e7303fae2e1a0e0b5
474478
475479
Ονομασία συναρτήσεων:
476480

1-js/02-first-steps/16-function-expressions/article.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Everything would work the same.
9090

9191

9292
````smart header="Why is there a semicolon at the end?"
93-
You might wonder, why does Function Expression have a semicolon `;` at the end, but Function Declaration does not:
93+
You might wonder, why do Function Expressions have a semicolon `;` at the end, but Function Declarations do not:
9494
9595
```js
9696
function sayHi() {
@@ -144,13 +144,13 @@ function showCancel() {
144144
ask("Do you agree?", showOk, showCancel);
145145
```
146146

147-
In practice, such functions are quite useful. The major difference between a real-life `ask` and the example above is that real-life functions use more complex ways to interact with the user than a simple `confirm`. In the browser, such function usually draws a nice-looking question window. But that's another story.
147+
In practice, such functions are quite useful. The major difference between a real-life `ask` and the example above is that real-life functions use more complex ways to interact with the user than a simple `confirm`. In the browser, such functions usually draw a nice-looking question window. But that's another story.
148148

149149
**The arguments `showOk` and `showCancel` of `ask` are called *callback functions* or just *callbacks*.**
150150

151151
The idea is that we pass a function and expect it to be "called back" later if necessary. In our case, `showOk` becomes the callback for "yes" answer, and `showCancel` for "no" answer.
152152

153-
We can use Function Expressions to write the same function much shorter:
153+
We can use Function Expressions to write an equivalent, shorter function:
154154

155155
```js run no-beautify
156156
function ask(question, yes, no) {
@@ -186,7 +186,7 @@ Let's formulate the key differences between Function Declarations and Expression
186186

187187
First, the syntax: how to differentiate between them in the code.
188188

189-
- *Function Declaration:* a function, declared as a separate statement, in the main code flow.
189+
- *Function Declaration:* a function, declared as a separate statement, in the main code flow:
190190

191191
```js
192192
// Function Declaration

1-js/03-code-quality/05-testing-mocha/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe("pow", function() {
5151
A spec has three main building blocks that you can see above:
5252

5353
`describe("title", function() { ... })`
54-
: What functionality we're describing. In our case we're describing the function `pow`. Used to group "workers" -- the `it` blocks.
54+
: What functionality we're describing? In our case we're describing the function `pow`. Used to group "workers" -- the `it` blocks.
5555

5656
`it("use case description", function() { ... })`
5757
: In the title of `it` we *in a human-readable way* describe the particular use case, and the second argument is a function that tests it.

1-js/04-object-basics/02-object-copy/article.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ And here's how it's actually stored in memory:
3737

3838
The object is stored somewhere in memory (at the right of the picture), while the `user` variable (at the left) has a "reference" to it.
3939

40-
We may think of an object variable, such as `user`, as like a sheet of paper with the address of the object on it.
40+
We may think of an object variable, such as `user`, like a sheet of paper with the address of the object on it.
4141

4242
When we perform actions with the object, e.g. take a property `user.name`, the JavaScript engine looks at what's at that address and performs the operation on the actual object.
4343

@@ -104,11 +104,9 @@ For comparisons like `obj1 > obj2` or for a comparison against a primitive `obj
104104
105105
So, copying an object variable creates one more reference to the same object.
106106
107-
But what if we need to duplicate an object? Create an independent copy, a clone?
107+
But what if we need to duplicate an object?
108108
109-
That's also doable, but a little bit more difficult, because there's no built-in method for that in JavaScript. But there is rarely a need -- copying by reference is good most of the time.
110-
111-
But if we really want that, then we need to create a new object and replicate the structure of the existing one by iterating over its properties and copying them on the primitive level.
109+
We can create a new object and replicate the structure of the existing one, by iterating over its properties and copying them on the primitive level.
112110
113111
Like this:
114112
@@ -133,7 +131,7 @@ clone.name = "Pete"; // changed the data in it
133131
alert( user.name ); // still John in the original object
134132
```
135133
136-
Also we can use the method [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) for that.
134+
We can also use the method [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign).
137135
138136
The syntax is:
139137
@@ -190,7 +188,7 @@ There are also other methods of cloning an object, e.g. using the [spread syntax
190188
191189
## Nested cloning
192190
193-
Until now we assumed that all properties of `user` are primitive. But properties can be references to other objects. What to do with them?
191+
Until now we assumed that all properties of `user` are primitive. But properties can be references to other objects.
194192
195193
Like this:
196194
```js run
@@ -205,9 +203,7 @@ let user = {
205203
alert( user.sizes.height ); // 182
206204
```
207205
208-
Now it's not enough to copy `clone.sizes = user.sizes`, because the `user.sizes` is an object, it will be copied by reference. So `clone` and `user` will share the same sizes:
209-
210-
Like this:
206+
Now it's not enough to copy `clone.sizes = user.sizes`, because `user.sizes` is an object, and will be copied by reference, so `clone` and `user` will share the same sizes:
211207
212208
```js run
213209
let user = {
@@ -224,10 +220,10 @@ alert( user.sizes === clone.sizes ); // true, same object
224220

225221
// user and clone share sizes
226222
user.sizes.width++; // change a property from one place
227-
alert(clone.sizes.width); // 51, see the result from the other one
223+
alert(clone.sizes.width); // 51, get the result from the other one
228224
```
229225
230-
To fix that, we should use a cloning loop that examines each value of `user[key]` and, if it's an object, then replicate its structure as well. That is called a "deep cloning".
226+
To fix that and make `user` and `clone` truly separate objects, we should use a cloning loop that examines each value of `user[key]` and, if it's an object, then replicate its structure as well. That is called a "deep cloning".
231227
232228
We can use recursion to implement it. Or, to not reinvent the wheel, take an existing implementation, for instance [_.cloneDeep(obj)](https://lodash.com/docs#cloneDeep) from the JavaScript library [lodash](https://lodash.com).
233229

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ alert( Symbol.keyFor(sym2) ); // id
238238

239239
The `Symbol.keyFor` internally uses the global symbol registry to look up the key for the symbol. So it doesn't work for non-global symbols. If the symbol is not global, it won't be able to find it and returns `undefined`.
240240

241-
That said, any symbols have `description` property.
241+
That said, all symbols have the `description` property.
242242

243243
For instance:
244244

1-js/05-data-types/01-primitives-methods/1-string-new-property/task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ str.test = 5;
1515
alert(str.test);
1616
```
1717

18-
How do you think, will it work? What will be shown?
18+
What do you think, will it work? What will be shown?

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ There are two ways to do so:
178178
alert( num.toFixed(1) ); // "12.4"
179179
```
180180

181-
Please note that result of `toFixed` is a string. If the decimal part is shorter than required, zeroes are appended to the end:
181+
Please note that the result of `toFixed` is a string. If the decimal part is shorter than required, zeroes are appended to the end:
182182

183183
```js run
184184
let num = 12.34;
@@ -246,7 +246,7 @@ Can we work around the problem? Sure, the most reliable method is to round the r
246246

247247
```js run
248248
let sum = 0.1 + 0.2;
249-
alert( sum.toFixed(2) ); // 0.30
249+
alert( sum.toFixed(2) ); // "0.30"
250250
```
251251

252252
Please note that `toFixed` always returns a string. It ensures that it has 2 digits after the decimal point. That's actually convenient if we have an e-shopping and need to show `$0.30`. For other cases, we can use the unary plus to coerce it into a number:

0 commit comments

Comments
 (0)