Glossary
Deep copy

Deep copy

In programming, a deep copy is a replica of an object that doesn’t share the same references as the original. That way, if you make changes to the duplicate, the original stays the same. On the other hand, a shallow copy shares the original’s properties and references, so if you change the copy, the original might change too.

Deep copies are common with C++, Python, and JavaScript programming because they avoid accidental changes. For example, you might copy an object to change it and accidentally alter the original, creating bugs in your code. Making a deep copy solves this problem by preserving the functioning code.

Python deep copy syntax appears as copy.deepcopy(x), where (x) is the object to be copied. C++ requires multiple lines of coding to make deep copies, which vary based on constrictors. JavaScript uses JSON.parse() functions to create new objects. While JavaScript does have standard built-in object-copy operations, you can only use them to create shallow copies.

Other glossary terms

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Hmm…we couldn’t find any results. Try a different search term or reset the filter.
Reset the filter
Load more