The keys method of the
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.
let map = new Map();map.set("one", 1);map.set("two", 2);map.set("three", 3);let keyIterator = map.keys();for(let key of keyIterator){console.log(key)}
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.