Skip to content

Commit a061883

Browse files
committed
resturcture the map section
1 parent 4cca6f0 commit a061883

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

en/es6-concepts/map.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@ description: Certainly! Let's discuss the `let` and `const` declarations in the
99
Map is a collection of keyed data items, just like an `Object`. But the main difference is that `Map` allows keys of any type.
1010

1111

12-
Methods and properties are:
13-
14-
`new Map()` – creates the map.
15-
`map.set(key, value)` – stores the value by the key.
16-
`map.get(key)` – returns the value by the key, undefined if key doesn’t exist in map.
17-
`map.has(key)` – returns true if the key exists, false otherwise.
18-
`map.delete(key)` – removes the element (the key/value pair) by the key.
19-
`map.clear()` – removes everything from the map.
20-
`map.size` – returns the current element count.
21-
22-
For example
12+
| Method/Property | Description |
13+
| ----------------------- | -------------------------------------------------------------------------------------------------- |
14+
| `new Map()` | Creates a new Map object. |
15+
| `map.set(key, value)` | Stores the `value` in the `map` object under the `key`. |
16+
| `map.get(key)` | Returns the `value` associated with the `key`, or `undefined` if the `key` doesn't exist. |
17+
| `map.has(key)` | Returns `true` if the `map` contains the `key`, otherwise returns `false`. |
18+
| `map.delete(key)` | Removes the element (key/value pair) from the `map` specified by the `key`. |
19+
| `map.clear()` | Removes all elements from the `map`. |
20+
| `map.size` | Returns the number of elements (key/value pairs) in the `map`. |
21+
22+
23+
An example of `Map()` with its various methods and properties is shown below.
2324
```sh
2425
let map = new Map();
2526

@@ -41,6 +42,6 @@ The differences from a regular `Object`:
4142

4243
* Additional convenient methods, the size property.
4344

44-
## Conclusion
45+
4546
Maps are a versatile and powerful data structure that provides key-value pairs for efficient data management.
4647
Maps are often a preferred choice over plain objects for tasks involving key-value associations, as they provide better control and performance.

0 commit comments

Comments
 (0)