Dr. Derek Austin 🥳
1 min readDec 4, 2019

--

Hi Nikoms, thanks for stopping by with your question about JSON.parse() and JSON.stringify().

I just updated the article to include 3 more methods of deep copying in JavaScript: writing a custom function, JSON.parse/JSON.stringify, and the rfdc (Really Fast Deep Clone) library.

Tuan Tran asked the same question in the response to the article, and he got a few responses with some good points. Check those out here:

Circular references are one issue, but not the only one — parse and stringify do not play nice with any data types that are not primitive values.

JSON.parse() and JSON.stringify() will only work for nested objects and arrays that contain just primitive values, objects, and arrays.

For example, Date and RegExp objects will not work correctly.

I illustrate some of these examples of JSON.parse() and JSON.stringify() using code in my updated article on how to deep copy in JavaScript.

--

--

Dr. Derek Austin 🥳
Dr. Derek Austin 🥳

Written by Dr. Derek Austin 🥳

Hi, I'm Doctor Derek! I've been a professional web developer since 2005, and I love writing about programming with JavaScript, TypeScript, React, Next.js & Git.

No responses yet