JavaScript: Map.prototype.values
New in JS2015.
map_obj.values()
- Return a Iterable (also is a Iterator) for the values in the map map_obj.
const mm = new Map([[3, "n3"], [4, "n4"], [5, "n5"] ]); for (let k of mm.values()) { console.log(k) } // prints // n3 // n4 // n5 for (let [k,v] of mm) { console.log(v) } // prints // n3 // n4 // n5
This example shows the result is iterator and iterable:
const mp = new Map( [[1,2], [3,4]]); console.log( mp.values ); // [Function: values] // result is a function that returns a iterator object // call it console.log( mp.values() ); // MapIterator { 1, 3 } // result is a iterator object // is also a iterable console.log( Symbol.iterator in ( mp.values() ) ); // true