JS: Map.prototype.keys
(new in ECMAScript 2015)
mapObj.keys()-
Return a Generator for the keys in the map.
const mm = new Map([[3, "n3"], [4, "n4"]]); for (let k of mm.keys()) { console.log(k); } // 3 // 4
Verify Result is a Generator
// verify the result is iterator and iterable const xx = (new Map([[1, 2], [3, 4]])).keys(); // is iterable console.log(Reflect.has(xx, Symbol.iterator)); // true // is iterator console.log(Reflect.has(xx, "next")); // true