) , [ `
Array.prototype.concat() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) , [ `
Array.prototype.slice() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) , [ `
Array.from() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) , and [ `
Object.assign() ` ](/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) ) create
shallow copies rather than deep copies.

Consider the following example, in which an ` ingredientsList ` array object
is created, and then an ` ingredientsListCopy ` object is created by copying
that ` ingredientsList ` object.

js

    
    
    const ingredientsList = ["noodles", { list: ["eggs", "flour", "water"] }];
    
    const ingredientsListCopy = Array.from(ingredientsList);
    console.log(ingredientsListCopy);
    // ["noodles",{"list":["eggs","flour","water"]}]
    

Re-assigning the value of a nested property will be visible in both objects.

js

    
    
    ingredientsListCopy[1].list = ["rice flour", "water"];
    console.log(ingredientsList[1].list);
    // Array [ "rice flour", "water" ]
    

Re-assigning the value of a top-level property (the ` 0 ` index in this case)
will only be visible in the changed object.

js

    
    
    ingredientsListCopy[0] = "rice noodles";
    console.log(ingredientsList[0]); // noodles
    console.log(JSON.stringify(ingredientsListCopy));
    // ["rice noodles",{"list":["rice flour","water"]}]
    console.log(JSON.stringify(ingredientsList));
    // ["noodles",{"list":["rice flour","water"]}]
    

##  See also

  * [ Deep copy ](/en-US/docs/Glossary/Deep_copy)

##  Help improve MDN

Was this page helpful to you?

Yes  No

[ Learn how to contribute
](https://github.com/mdn/content/blob/main/CONTRIBUTING.md "This will take you
to our contribution guidelines on GitHub.") .

This page was last modified on  Mar 28, 2024  by  [ MDN contributors ](/en-
US/docs/Glossary/Shallow_copy/contributors.txt) .

[ View this page on GitHub
](https://github.com/mdn/content/blob/main/files/en-
us/glossary/shallow_copy/index.md?plain=1 "Folder: en-us/glossary/shallow_copy
\(Opens in a new tab\)") â¢  [ Report a problem with this content
](https://github.com/mdn/content/issues/new?template=page-report.yml&mdn-
url=https%3A%2F%2Fdeveloper.mozilla.org%2Fen-
US%2Fdocs%2FGlossary%2FShallow_copy&metadata=%3C%21--+Do+not+make+changes+below+this+line+--%3E%0A%3Cdetails%3E%0A%3Csummary%3EPage+report+details%3C%2Fsummary%3E%0A%0A*+Folder%3A+%60en-
us%2Fglossary%2Fshallow_copy%60%0A*+MDN+URL%3A+https%3A%2F%2Fdeveloper.mozilla.org%2Fen-
US%2Fdocs%2FGlossary%2FShallow_copy%0A*+GitHub+URL%3A+https%3A%2F%2Fgithub.com%2Fmdn%2Fcontent%2Fblob%2Fmain%2Ffiles%2Fen-
us%2Fglossary%2Fshallow_copy%2Findex.md%0A*+Last+commit%3A+https%3A%2F%2Fgithub.com%2Fmdn%2Fcontent%2Fcommit%2F3114504a9746114aa5501656b76198e85d7af901%0A*+Document+last+modified%3A+2024-03-28T02%3A48%3A10.000Z%0A%0A%3C%2Fdetails%3E
"This will take you to GitHub to file a new issue.")

[ MDN logo  ](/)

Your blueprint for a better internet.

  * [ MDN on Mastodon  ](https://mozilla.social/@mdn)
  * [ MDN on X (formerly Twitter)  ](https://twitter.com/mozdevnet)
  * [ MDN on GitHub  ](https://github.com/mdn/)
  * [ MDN Blog RSS Feed  ](/en-US/blog/rss.xml)

##  MDN

  * [ About ](/en-US/about)
  * [ Blog ](/en-US/blog/)
  * [ Careers ](https://www.mozilla.org/en-US/careers/listings/?team=ProdOps)
  * [ Advertise with us ](/en-US/advertising)

##  Support

  * [ Product help ](https://support.mozilla.org/products/mdn-plus)
  * [ Report an issue ](/en-US/docs/MDN/Community/Issues)

##  Our communities

  * [ MDN Community ](/en-US/community)
  * [ MDN Forum ](https://discourse.mozilla.org/c/mdn/236)
  * [ MDN Chat ](/discord)

##  Developers

  * [ Web Technologies ](/en-US/docs/Web)
  * [ Learn Web Development ](/en-US/docs/Learn)
  * [ MDN Plus ](/en-US/plus)
  * [ Hacks Blog ](https://hacks.mozilla.org/)

[ Mozilla logo  ](https://www.mozilla.org/)

  * [ Webs