Reputation: 353
I must be missing something here. I try to put a value into a map but it doesn't want to work.
const tempMap = new Map();
tempMap.set("bla", "bla");
console.log(tempMap)
--> output: {}
Can someone explain to me why it is like that? Shouldn't the output have the added value in it?
Try it yourself in the playground.
Upvotes: 2
Views: 1806
Reputation: 353
In the end I used the Record
type for my purpose. Which is a kind of dictionary type.
Upvotes: 0
Reputation: 2916
The class itself won't export any values, use should use the API
You want to do something like this:
let tmpMap = new Map();
tmpMap.set("bla", "bla");
console.log(tmpMap.get('bla')); // bla
You can also iterate in tempMap.keys()
or tempMap.values()
like @Evan already commented.
Upvotes: 3