Skip to main content
The 2024 Developer Survey results are live! See the results

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • This one is nice but does require you to target ES2019. Commented Jun 23, 2021 at 11:36
  • 1
    Careful, this is just good if you want to go one way.Object.fromEntries() as stated in the MDN Docs you can parse a Map to an Object but not back! It will throw a object is not iterable error.
    – Megajin
    Commented Mar 21, 2022 at 13:53
  • @Megajin Object.fromEntries() is non-destructive, so you will still have your original Map intact. Commented Apr 6, 2022 at 7:35
  • 1
    @AlokSomani yes, you are right. However if you want to parse a JSON (or the newly created Object) back, it won't work.
    – Megajin
    Commented Apr 6, 2022 at 12:12
  • 1
    Just for additional information, this is totally ok for Typescript users which are able to make sure that the whole map structure (meaning nested objects as well) have string keys Map<string, otherType> Commented Mar 24, 2023 at 14:02