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/05-data-types/07-map-set/article.md
+7-8Lines changed: 7 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ But that's not enough for real life. That's why `Map` and `Set` also exist.
14
14
15
15
Methods and properties are:
16
16
17
-
-`new Map()` -- creates the map.
17
+
-[`new Map()`](mdn:js/Map/Map) -- creates the map.
18
18
-[`map.set(key, value)`](mdn:js/Map/set) -- stores the value by the key.
19
19
-[`map.get(key)`](mdn:js/Map/get) -- returns the value by the key, `undefined` if `key` doesn't exist in map.
20
20
-[`map.has(key)`](mdn:js/Map/has) -- returns `true` if the `key` exists, `false` otherwise.
@@ -100,7 +100,6 @@ 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:
@@ -233,11 +232,11 @@ 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`](mdn:js/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.
239
+
- [`new Set(iterable)`](mdn:js/Set/Set) -- creates the set, and if an `iterable` object is provided (usually an array), copies values from it into the set.
241
240
- [`set.add(value)`](mdn:js/Set/add) -- adds a value, returns the set itself.
242
241
- [`set.delete(value)`](mdn:js/Set/delete) -- removes the value, returns `true` if `value` existed at the moment of the call, otherwise `false`.
243
242
- [`set.has(value)`](mdn:js/Set/has) -- returns `true` if the value exists in the set, otherwise `false`.
@@ -301,11 +300,11 @@ The same methods `Map` has for iterators are also supported:
301
300
302
301
## Summary
303
302
304
-
`Map` -- is a collection of keyed values.
303
+
[Map](mdn:js/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.
307
+
- [`new Map([iterable])`](mdn:js/Map/Map) -- creates the map, with optional `iterable` (e.g. array) of `[key,value]` pairs for initialization.
309
308
- [`map.set(key, value)`](mdn:js/Map/set) -- stores the value by the key, returns the map itself.
310
309
- [`map.get(key)`](mdn:js/Map/get) -- returns the value by the key, `undefined` if `key` doesn't exist in map.
311
310
- [`map.has(key)`](mdn:js/Map/has) -- returns `true` if the `key` exists, `false` otherwise.
@@ -318,11 +317,11 @@ The differences from a regular `Object`:
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`](mdn:js/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.
324
+
- [`new Set(iterable)`](mdn:js/Set/Set) -- creates the set, with optional `iterable` (e.g. array) of values for initialization.
326
325
- [`set.add(value)`](mdn:js/Set/add) -- adds a value (does nothing if `value` exists), returns the set itself.
327
326
- [`set.delete(value)`](mdn:js/Set/delete) -- removes the value, returns `true` if `value` existed at the moment of the call, otherwise `false`.
328
327
- [`set.has(value)`](mdn:js/Set/has) -- returns `true` if the value exists in the set, otherwise `false`.
0 commit comments