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 →

Elsewhere ,

One Response to Making a Deep Copy of an Object in JavaScript

Leave a 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.