Map data structures
Map data structures
what I will be covering in this article
- What is the map data structure.
- How to use the map data structure.
- When to use the map data structure.
What is the map data structure
Map allows keys of any type unlike an Object which is very like a Map.
Methods and properties are:
new Map() – creates a new map.
map.set(key, value) – sets the value by the key returns the set.
map.delete(key) – removes the value by the key.
map.get(key) – returns the value by the key, or undefined if key doesn’t exist.
map.has(key) – returns true if the key exists, false otherwise.
map.clear() – clears the map compleately removing all values and keys.
map.size – returns the current element count.
map.forEach()
map.size – returns the current element count.
map.forEach() – iterate of the map similar to how it would work with an array.
How to use the map data structure.
Next Article: The Set data structure