The keys
method of the Map object will return the keys of all the map entries.
mapObj.keys()
The keys()
method will return an iterator object. The returned iterator object contains all the keys of the map in the insertion order.
In the code above:
We have created a Map
object and added some entries to it.
Then called the keys
method to get all the keys of the map objects.
Then printed the iterator object returned by the keys
method using the for...of
loop.