@@ -9,17 +9,18 @@ description: Certainly! Let's discuss the `let` and `const` declarations in the
99Map 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
2425let 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+
4546Maps are a versatile and powerful data structure that provides key-value pairs for efficient data management.
4647Maps are often a preferred choice over plain objects for tasks involving key-value associations, as they provide better control and performance.
0 commit comments