Making a Deep Copy of an Object in JavaScript

In JavaScript, when cloning an object via Object.assign({}, obj) or by destructuring it (e.g.{...obj}, only shallow copies are created.

Surma has explored some unusual ways – other than JSON.parse(JSON.stringify(obj)); to create an actual deep copy:

  1. MessageChannel
  2. History API
  3. Notification API

(told you they were unusual ;))

Deep-copying in JavaScript →

About the Author

Bramus is a Freelance Web Developer from Belgium. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Join the Conversation

1 Comment

Leave a comment

Leave a Reply to Binyamin Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.