--

Hey Jefferson, thanks so much for your kind words! That's a great question -- actually cloning with the spread operator is a shallow clone, whereas cloning with Stringify and Parse is a deep clone. It's one of my favorite subjects, so let me share 2 of my other articles with you.

https://javascript.plainenglish.io/how-to-deep-copy-objects-and-arrays-in-javascript-7c911359b089

https://javascript.plainenglish.io/dont-deep-copy-with-json-stringify-and-json-parse-in-js-here-s-why-c3f2783661e9

--

--

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