--

Hi Glenn! Thanks for the message. Your example is only a shallow clone, so the nested array inside the object will still have the same pointer.

In the example from this article, I wrapped that shallow clone (your doppelganger) in JSON.parse and JSON.stringify to make a deep clone.

That piece of things wasn't clear, so I added a few more lines to clarify. Thanks for mentioning it!

--

--

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