Deep Clone objects the right way in JavaScript!

_.cloneDeep() or JSON.parse(JSON.string())? Neither! There’s now a native method to address this.

Harsha Vardhan
JavaScript in Plain English
4 min readFeb 16, 2023

--

Photo by Jen Theodore on Unsplash

Have you ever come across a situation where you will have to deep copy an object in your code, and you had to use either JSON.parse(JSON.stringify(obj)) or Loadash’s cloneDeep() ? Both of these have their pros and cons…

--

--

Engineer, Photographer, Tech Blogger. Builds products and writes for developers. I love to code and love to help others code :)