DEV Community

Discussion on: JavaScript Interviews: Create a deep copy of an object

Collapse
 
sgoulas profile image
sgoulas

This is indeed a nice trick, but do keep in mind that in order for this to work the object must not contain dates, functions, undefined, infinity, nan, regexes, maps, sets, blobs, file lists, image data, sparce / typed arrays or any other complex types. For the majority of the cases though it will do the trick.

Collapse
 
garystorey profile image
Gary Storey

If there had been any of the above mentioned, then I would not have recommended my approach.

As you stated this works in the majority of situations and for the examples given.