JS: Map.prototype.values

By Xah Lee. Date: . Last updated: .

(new in JS: ECMAScript 2015)

mapObj.values()

Return a Generator for the values in the map.

console.log(
  JSON.stringify(
    Array.from(
      (new Map([[3, "n3"], [4, "n4"], [5, "n5"]])).values(),
    ),
  ) === `["n3","n4","n5"]`,
);

Verify Result is a Generator

// verify the result is iterator and iterable

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

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

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

JS Map.prototype