You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/05-types/article.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -236,7 +236,11 @@ alert(age); // "undefined"
236
236
237
237
## Ο τελεστής `typeof` [#type-typeof]
238
238
239
+
<<<<<<< HEAD
239
240
Ο τελεστής `typeof` επιστρέφει τον τύπο του ορίσματος. Είναι χρήσιμο όταν θέλουμε να επεξεργαστούμε διαφορετικές τιμές διαφορετικών τύπων ή απλώς να κάνουμε έναν γρήγορο έλεγχο.
241
+
=======
242
+
The `typeof` operator returns the type of the operand. It's useful when we want to process values of different types differently or just want to do a quick check.
Copy file name to clipboardExpand all lines: 1-js/05-data-types/03-string/article.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -505,7 +505,7 @@ This method actually has two additional arguments specified in [the documentatio
505
505
506
506
- There are 3 types of quotes. Backticks allow a string to span multiple lines and embed expressions `${…}`.
507
507
- We can use special characters, such as a line break `\n`.
508
-
- To get a character, use: `[]`.
508
+
- To get a character, use: `[]` or `at` method.
509
509
- To get a substring, use: `slice` or `substring`.
510
510
- To lowercase/uppercase a string, use: `toLowerCase/toUpperCase`.
511
511
- To look for a substring, use: `indexOf`, or `includes/startsWith/endsWith` for simple checks.
@@ -519,4 +519,4 @@ There are several other helpful methods in strings:
519
519
520
520
Strings also have methods for doing search/replace with regular expressions. But that's big topic, so it's explained in a separate tutorial section <info:regular-expressions>.
521
521
522
-
Also, as of now it's important to know that strings are based on Unicode encoding, and hence there're issues with comparisons. There's more about Unicode in the chapter <info:unicode>.
522
+
Also, as of now it's important to know that strings are based on Unicode encoding, and hence there're issues with comparisons. There's more about Unicode in the chapter <info:unicode>.
Copy file name to clipboardExpand all lines: 1-js/05-data-types/07-map-set/article.md
+38-39Lines changed: 38 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,17 +10,17 @@ But that's not enough for real life. That's why `Map` and `Set` also exist.
10
10
11
11
## Map
12
12
13
-
[Map](mdn:js/Map) is a collection of keyed data items, just like an `Object`. But the main difference is that `Map` allows keys of any type.
13
+
[Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) is a collection of keyed data items, just like an `Object`. But the main difference is that `Map` allows keys of any type.
14
14
15
15
Methods and properties are:
16
16
17
-
-`new Map()` -- creates the map.
18
-
-[`map.set(key, value)`](mdn:js/Map/set) -- stores the value by the key.
19
-
-[`map.get(key)`](mdn:js/Map/get) -- returns the value by the key, `undefined` if `key` doesn't exist in map.
20
-
-[`map.has(key)`](mdn:js/Map/has) -- returns `true` if the `key` exists, `false` otherwise.
21
-
-[`map.delete(key)`](mdn:js/Map/delete) -- removes the value by the key.
22
-
-[`map.clear()`](mdn:js/Map/clear) -- removes everything from the map.
23
-
-[`map.size`](mdn:js/Map/size) -- returns the current element count.
17
+
-[`new Map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/Map) -- creates the map.
18
+
-[`map.set(key, value)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set) -- stores the value by the key.
19
+
-[`map.get(key)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get) -- returns the value by the key, `undefined` if `key` doesn't exist in map.
20
+
-[`map.has(key)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has) -- returns `true` if the `key` exists, `false` otherwise.
21
+
-[`map.delete(key)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete) -- removes the value by the key.
22
+
-[`map.clear()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear) -- removes everything from the map.
23
+
-[`map.size`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size) -- returns the current element count.
24
24
25
25
For instance:
26
26
@@ -100,14 +100,13 @@ map.set('1', 'str1')
100
100
```
101
101
````
102
102
103
-
104
103
## Iteration over Map
105
104
106
105
For looping over a `map`, there are 3 methods:
107
106
108
-
- [`map.keys()`](mdn:js/Map/keys) -- returns an iterable for keys,
109
-
- [`map.values()`](mdn:js/Map/values) -- returns an iterable for values,
110
-
- [`map.entries()`](mdn:js/Map/entries) -- returns an iterable for entries `[key, value]`, it's used by default in `for..of`.
107
+
- [`map.keys()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys) -- returns an iterable for keys,
108
+
- [`map.values()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values) -- returns an iterable for values,
109
+
- [`map.entries()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/entries) -- returns an iterable for entries `[key, value]`, it's used by default in `for..of`.
111
110
112
111
For instance:
113
112
@@ -162,7 +161,7 @@ let map = new Map([
162
161
alert( map.get('1') ); // str1
163
162
```
164
163
165
-
If we have a plain object, and we'd like to create a `Map` from it, then we can use built-in method [Object.entries(obj)](mdn:js/Object/entries) that returns an array of key/value pairs for an object exactly in that format.
164
+
If we have a plain object, and we'd like to create a `Map` from it, then we can use built-in method [Object.entries(obj)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries) that returns an array of key/value pairs for an object exactly in that format.
166
165
167
166
So we can create a map from an object like this:
168
167
@@ -233,16 +232,16 @@ That's the same, because `Object.fromEntries` expects an iterable object as the
233
232
234
233
## Set
235
234
236
-
A `Set` is a special type collection - "set of values" (without keys), where each value may occur only once.
235
+
A [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) is a special type collection - "set of values" (without keys), where each value may occur only once.
237
236
238
237
Its main methods are:
239
238
240
-
- `new Set(iterable)` -- creates the set, and if an `iterable` object is provided (usually an array), copies values from it into the set.
241
-
- [`set.add(value)`](mdn:js/Set/add) -- adds a value, returns the set itself.
242
-
- [`set.delete(value)`](mdn:js/Set/delete) -- removes the value, returns `true` if `value` existed at the moment of the call, otherwise `false`.
243
-
- [`set.has(value)`](mdn:js/Set/has) -- returns `true` if the value exists in the set, otherwise `false`.
244
-
- [`set.clear()`](mdn:js/Set/clear) -- removes everything from the set.
245
-
- [`set.size`](mdn:js/Set/size) -- is the elements count.
239
+
- [`new Set([iterable])`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/Set) -- creates the set, and if an `iterable` object is provided (usually an array), copies values from it into the set.
240
+
- [`set.add(value)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add) -- adds a value, returns the set itself.
241
+
- [`set.delete(value)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete) -- removes the value, returns `true` if `value` existed at the moment of the call, otherwise `false`.
242
+
- [`set.has(value)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has) -- returns `true` if the value exists in the set, otherwise `false`.
243
+
- [`set.clear()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear) -- removes everything from the set.
244
+
- [`set.size`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/size) -- is the elements count.
246
245
247
246
The main feature is that repeated calls of `set.add(value)` with the same value don't do anything. That's the reason why each value appears in a `Set` only once.
248
247
@@ -272,7 +271,7 @@ for (let user of set) {
272
271
}
273
272
```
274
273
275
-
The alternative to `Set` could be an array of users, and the code to check for duplicates on every insertion using [arr.find](mdn:js/Array/find). But the performance would be much worse, because this method walks through the whole array checking every element. `Set` is much better optimized internally for uniqueness checks.
274
+
The alternative to `Set` could be an array of users, and the code to check for duplicates on every insertion using [arr.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find). But the performance would be much worse, because this method walks through the whole array checking every element. `Set` is much better optimized internally for uniqueness checks.
276
275
277
276
## Iteration over Set
278
277
@@ -295,38 +294,38 @@ That's for compatibility with `Map` where the callback passed `forEach` has thre
295
294
296
295
The same methods `Map` has for iterators are also supported:
297
296
298
-
- [`set.keys()`](mdn:js/Set/keys) -- returns an iterable object for values,
299
-
- [`set.values()`](mdn:js/Set/values) -- same as `set.keys()`, for compatibility with `Map`,
300
-
- [`set.entries()`](mdn:js/Set/entries) -- returns an iterable object for entries `[value, value]`, exists for compatibility with `Map`.
297
+
- [`set.keys()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/keys) -- returns an iterable object for values,
298
+
- [`set.values()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values) -- same as `set.keys()`, for compatibility with `Map`,
299
+
- [`set.entries()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/entries) -- returns an iterable object for entries `[value, value]`, exists for compatibility with `Map`.
301
300
302
301
## Summary
303
302
304
-
`Map` -- is a collection of keyed values.
303
+
[`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) -- is a collection of keyed values.
305
304
306
305
Methods and properties:
307
306
308
-
- `new Map([iterable])` -- creates the map, with optional `iterable` (e.g. array) of `[key,value]` pairs for initialization.
309
-
- [`map.set(key, value)`](mdn:js/Map/set) -- stores the value by the key, returns the map itself.
310
-
- [`map.get(key)`](mdn:js/Map/get) -- returns the value by the key, `undefined` if `key` doesn't exist in map.
311
-
- [`map.has(key)`](mdn:js/Map/has) -- returns `true` if the `key` exists, `false` otherwise.
312
-
- [`map.delete(key)`](mdn:js/Map/delete) -- removes the value by the key, returns `true` if `key` existed at the moment of the call, otherwise `false`.
313
-
- [`map.clear()`](mdn:js/Map/clear) -- removes everything from the map.
314
-
- [`map.size`](mdn:js/Map/size) -- returns the current element count.
307
+
- [`new Map([iterable])`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/Map) -- creates the map, with optional `iterable` (e.g. array) of `[key,value]` pairs for initialization.
308
+
- [`map.set(key, value)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set) -- stores the value by the key, returns the map itself.
309
+
- [`map.get(key)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get) -- returns the value by the key, `undefined` if `key` doesn't exist in map.
310
+
- [`map.has(key)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has) -- returns `true` if the `key` exists, `false` otherwise.
311
+
- [`map.delete(key)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete) -- removes the value by the key, returns `true` if `key` existed at the moment of the call, otherwise `false`.
312
+
- [`map.clear()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear) -- removes everything from the map.
313
+
- [`map.size`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size) -- returns the current element count.
315
314
316
315
The differences from a regular `Object`:
317
316
318
317
- Any keys, objects can be keys.
319
318
- Additional convenient methods, the `size` property.
320
319
321
-
`Set` -- is a collection of unique values.
320
+
[`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) -- is a collection of unique values.
322
321
323
322
Methods and properties:
324
323
325
-
- `new Set([iterable])` -- creates the set, with optional `iterable` (e.g. array) of values for initialization.
326
-
- [`set.add(value)`](mdn:js/Set/add) -- adds a value (does nothing if `value` exists), returns the set itself.
327
-
- [`set.delete(value)`](mdn:js/Set/delete) -- removes the value, returns `true` if `value` existed at the moment of the call, otherwise `false`.
328
-
- [`set.has(value)`](mdn:js/Set/has) -- returns `true` if the value exists in the set, otherwise `false`.
329
-
- [`set.clear()`](mdn:js/Set/clear) -- removes everything from the set.
330
-
- [`set.size`](mdn:js/Set/size) -- is the elements count.
324
+
- [`new Set([iterable])`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/Set) -- creates the set, with optional `iterable` (e.g. array) of values for initialization.
325
+
- [`set.add(value)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add) -- adds a value (does nothing if `value` exists), returns the set itself.
326
+
- [`set.delete(value)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete) -- removes the value, returns `true` if `value` existed at the moment of the call, otherwise `false`.
327
+
- [`set.has(value)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/has) -- returns `true` if the value exists in the set, otherwise `false`.
328
+
- [`set.clear()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear) -- removes everything from the set.
329
+
- [`set.size`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/size) -- is the elements count.
331
330
332
331
Iteration over `Map` and `Set` is always in the insertion order, so we can't say that these collections are unordered, but we can't reorder elements or directly get an element by its number.
0 commit comments