<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/shallow-copy-and-deep-copy-in-js--aisvkfx5" -->

---
title: Shallow Copy and Deep Copy in JS | daily.dev
description: Shallow Copy means creating new references to the primitive values inside the object, copying them. A shallow copy refers to the fact that only one level is...
canonical: https://daily.dev/posts/shallow-copy-and-deep-copy-in-js--aisvkfx5
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Shallow Copy and Deep Copy in JS | daily.dev
og:description: Shallow Copy means creating new references to the primitive values inside the object, copying them. A shallow copy refers to the fact that only one level is...
og:url: https://daily.dev/posts/shallow-copy-and-deep-copy-in-js--aisvkfx5
og:image: https://api.daily.dev/og/posts/-aiSvkfx5.png
og:image:alt: Shallow Copy and Deep Copy in JS
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Shallow Copy and Deep Copy in JS

**[DevDojo](https://daily.dev/sources/devdojo)** · [@rahxul](https://daily.dev/rahxul) · 5 min read · 10 upvotes · 1 comments

## Summary

Shallow Copy means creating new references to the primitive values inside the object, copying them. A shallow copy refers to the fact that only one level is copied, and that will work fine for an array or object containing only primitive values. For objects and arrays containing other objects or arrays, copying these objects requires a deep copy. Changes made to be nested references will change the data nested in the original object or array.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://devdojo.com/rahulism/shallow-copy-and-deep-copy-in-js>

## Community discussion

Top comments from developers on daily.dev.

**@greeshmamedam** · 0 upvotes

> Well Explained!

---

Tags: [#javascript](https://daily.dev/tags/javascript)

[View this post on daily.dev](https://daily.dev/posts/shallow-copy-and-deep-copy-in-js--aisvkfx5)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Shallow Copy and Deep Copy in JS","url":"https://daily.dev/posts/shallow-copy-and-deep-copy-in-js--aisvkfx5","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/shallow-copy-and-deep-copy-in-js--aisvkfx5"},"datePublished":"2021-12-27T00:12:48.704Z","dateModified":"2021-12-27T00:12:48.704Z","description":"Shallow Copy means creating new references to the primitive values inside the object, copying them. A shallow copy refers to the fact that only one level is...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/eeb57575191a197fcce6c4f8a7fa75b8","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/eeb57575191a197fcce6c4f8a7fa75b8","isAccessibleForFree":true,"articleSection":"DevDojo","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Person","name":"Rahul","url":"https://daily.dev/rahxul","image":"https://media.daily.dev/image/upload/s--w_EB7y0c--/f_auto,q_auto/v1/avatars/avatar_UA2asvbfX","description":"Hustler","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":2120}},"commentCount":1,"discussionUrl":"https://daily.dev/posts/shallow-copy-and-deep-copy-in-js--aisvkfx5","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":10},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"javascript","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"DevDojo","item":"https://daily.dev/sources/devdojo"},{"@type":"ListItem","position":3,"name":"Shallow Copy and Deep Copy in JS"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/shallow-copy-and-deep-copy-in-js--aisvkfx5","comment":[{"@type":"Comment","text":"Well Explained!","datePublished":"2021-12-27T02:30:53.430Z","url":"https://daily.dev/posts/-aiSvkfx5#c-agGCjpRMT","author":{"@type":"Person","name":"M Greeshma","url":"https://daily.dev/greeshmamedam","image":"https://media.daily.dev/image/upload/f_auto/v1635272054/avatars/U1iJlqPMgiE503TsTtKHQ"}}]}
```

