DEV Community

Discussion on: Classic issues: Deep Copy

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

JSON.stringify not working for you? Just use YAML.

Also, JSON functions' second arg can used to notify of object types.

I wrote a custom serialization some time ago.

GitHub logo patarapolw / any-serialize

Serialize any JavaScript objects, as long as you provides how-to. I have already provided Date, RegExp and Function.

I normally wouldn't just trust lodash for deepclone or deepmerge. So, I would write a minimal version for my own.

Collapse
 
disgustingdev profile image
disgusting-dev

Thank you for comment mate, and the serialization looks very mature

JSON usually works fine, it was mentioned there as a highlighter that "this is helpful not in 100% of cases", for 100% let's say that everyone will need to write/reuse what you wrote, which shows some necessity of corner cases development rather than JSON.stringify(JSON.parse)