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.

22
  • 14
    Just marked this as correct. While I don't like the fact you have to "dirty up" the data across the wire with a non-standardized dataType, I can't think of a cleaner way. Thanks.
    – rynop
    Commented Oct 9, 2020 at 18:07
  • 3
    @Pawel what is the reason for using this[key] instead of value?
    – JimiDini
    Commented Jan 21, 2021 at 14:59
  • 2
    To me there seems to be a slight problem: any ordinary object o which by chance has the property o.dataType==='Map' will also be converted to a Map when you serialize-deserialize it.
    – mkoe
    Commented Jul 15, 2021 at 19:42
  • 4
    @mkoe sure, but the probability of that is somewhere between being hit by a lightning and being hit by a lightning while hiding in a basement
    – Pawel
    Commented Sep 3, 2021 at 13:40
  • 2
    If anyone is tempted to use Object.fromEntries() as stated in the MDN Docs I highly advise against it. 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:49