Re:HTML Attributes vs. DOM Properties
by londons_explore on Thursday April 25, 2024 @09:07AM
(#40157053)
Same is true of real javascript objects vs JSON. For example, you can't put Date() in JSON. Nor objects with a prototype.
[ Parent
| on HN ]
I do want to point out for those who don't know, on objects with a prototype (such as a class) you can control how JSON.stringify works by adding a special method `toJSON`[0] which will control how that object is serialized.
[0]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...