Quantcast
Channel: How to convert a plain object into an ES6 Map? - Stack Overflow
Viewing all articles
Browse latest Browse all 7

How to convert a plain object into an ES6 Map?

$
0
0

For some reason I can't find this simple thing in the MDN docs (maybe I'm just missing it).

I expected this to work:

const map = new Map({foo: 'bar'});map.get('foo'); // 'bar'

...but the first line throws TypeError: (var)[Symbol.iterator] is not a function

How do I make a Map from a plain object? Do I really have to first convert it into an array of arrays of key-value pairs?


Viewing all articles
Browse latest Browse all 7

Trending Articles