👾 add mdn links to Map and Set methods
This commit is contained in:
parent
53b35c1683
commit
11eef4c69a
1 changed files with 9 additions and 9 deletions
|
@ -15,12 +15,12 @@ But that's not enough for real life. That's why `Map` and `Set` also exist.
|
||||||
Methods and properties are:
|
Methods and properties are:
|
||||||
|
|
||||||
- `new Map()` -- creates the map.
|
- `new Map()` -- creates the map.
|
||||||
- `map.set(key, value)` -- stores the value by the key.
|
- [`map.set(key, value)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set) -- stores the value by the key.
|
||||||
- `map.get(key)` -- returns the value by the key, `undefined` if `key` doesn't exist in map.
|
- [`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.
|
||||||
- `map.has(key)` -- returns `true` if the `key` exists, `false` otherwise.
|
- [`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.
|
||||||
- `map.delete(key)` -- removes the value by the key.
|
- [`map.delete(key)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete) -- removes the value by the key.
|
||||||
- `map.clear()` -- removes everything from the map.
|
- [`map.clear()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear) -- removes everything from the map.
|
||||||
- `map.size` -- returns the current element count.
|
- [`map.size`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size) -- returns the current element count.
|
||||||
|
|
||||||
For instance:
|
For instance:
|
||||||
|
|
||||||
|
@ -105,9 +105,9 @@ map.set('1', 'str1')
|
||||||
|
|
||||||
For looping over a `map`, there are 3 methods:
|
For looping over a `map`, there are 3 methods:
|
||||||
|
|
||||||
- `map.keys()` -- returns an iterable for keys,
|
- [`map.keys()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/keys) -- returns an iterable for keys,
|
||||||
- `map.values()` -- returns an iterable for values,
|
- [`map.values()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/values) -- returns an iterable for values,
|
||||||
- `map.entries()` -- returns an iterable for entries `[key, value]`, it's used by default in `for..of`.
|
- [`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`.
|
||||||
|
|
||||||
For instance:
|
For instance:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue