Example of Map in Javascript ES6
With ES6, we have Map where we can store key value pairs using the “set” method…
We get elements out using “get” method. The map has a property of size to indicate the number of elements.
We can get all keys and get all values using keys() and values(). But a better way might be to iterate over all elements using for-of loop and destructuring.
More Map Methods
We can delete an element using delete() and delete all elements using clear(). The has() method will tell you if there is an element with a specific key.