I have the following code:
const x = new Map([['key', 'value']])
Now, I want to stringify this. I used the following:
JSON.stringify(x)
...which gave me an empty object.
How do you actually perform the stringification on new Map()
? Is it something like you first turn it into an object and then stringify it?
I am expecting the output to be {"key": "value"}
.