Skip to content

Commit 82156c4

Browse files
authored
👾 smth
1 parent 11eef4c commit 82156c4

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

1-js/05-data-types/07-map-set/article.md

+28-28
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ But that's not enough for real life. That's why `Map` and `Set` also exist.
1515
Methods and properties are:
1616

1717
- `new 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.
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.
2424

2525
For instance:
2626

@@ -105,9 +105,9 @@ map.set('1', 'str1')
105105
106106
For looping over a `map`, there are 3 methods:
107107
108-
- [`map.keys()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys) -- returns an iterable for keys,
109-
- [`map.values()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values) -- returns an iterable for values,
110-
- [`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`.
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`.
111111
112112
For instance:
113113
@@ -238,11 +238,11 @@ A `Set` is a special type collection - "set of values" (without keys), where eac
238238
Its main methods are:
239239
240240
- `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)` -- adds a value, returns the set itself.
242-
- `set.delete(value)` -- removes the value, returns `true` if `value` existed at the moment of the call, otherwise `false`.
243-
- `set.has(value)` -- returns `true` if the value exists in the set, otherwise `false`.
244-
- `set.clear()` -- removes everything from the set.
245-
- `set.size` -- is the elements count.
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.
246246
247247
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.
248248
@@ -295,9 +295,9 @@ That's for compatibility with `Map` where the callback passed `forEach` has thre
295295
296296
The same methods `Map` has for iterators are also supported:
297297
298-
- `set.keys()` -- returns an iterable object for values,
299-
- `set.values()` -- same as `set.keys()`, for compatibility with `Map`,
300-
- `set.entries()` -- returns an iterable object for entries `[value, value]`, exists for compatibility with `Map`.
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`.
301301
302302
## Summary
303303
@@ -306,12 +306,12 @@ The same methods `Map` has for iterators are also supported:
306306
Methods and properties:
307307
308308
- `new Map([iterable])` -- creates the map, with optional `iterable` (e.g. array) of `[key,value]` pairs for initialization.
309-
- `map.set(key, value)` -- stores the value by the key, returns the map itself.
310-
- `map.get(key)` -- returns the value by the key, `undefined` if `key` doesn't exist in map.
311-
- `map.has(key)` -- returns `true` if the `key` exists, `false` otherwise.
312-
- `map.delete(key)` -- removes the value by the key, returns `true` if `key` existed at the moment of the call, otherwise `false`.
313-
- `map.clear()` -- removes everything from the map.
314-
- `map.size` -- returns the current element count.
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.
315315
316316
The differences from a regular `Object`:
317317
@@ -323,10 +323,10 @@ The differences from a regular `Object`:
323323
Methods and properties:
324324
325325
- `new Set([iterable])` -- creates the set, with optional `iterable` (e.g. array) of values for initialization.
326-
- `set.add(value)` -- adds a value (does nothing if `value` exists), returns the set itself.
327-
- `set.delete(value)` -- removes the value, returns `true` if `value` existed at the moment of the call, otherwise `false`.
328-
- `set.has(value)` -- returns `true` if the value exists in the set, otherwise `false`.
329-
- `set.clear()` -- removes everything from the set.
330-
- `set.size` -- is the elements count.
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.
331331
332332
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

Comments
 (0)