JS: Map.prototype.values

By Xah Lee. Date: . Last updated: .

(new in ECMAScript 2015)

mapObj.values()

Return a Generator for the values in the map.

const mm = new Map([[3, "aa"], [4, "bb"]]);
for (let v of mm.values()) {
 console.log(v);
}
// aa
// bb

Verify Result is a Generator

// verify the result is iterator and iterable

const xx = (new Map([[1, 2], [3, 4]])).values();

// is iterable
console.assert(
 Reflect.has(xx, Symbol.iterator),
);

// is iterator
console.assert(
 Reflect.has(xx, "next"),
);