Shallow Copy
noun
say it: “SHAL-oh KOP-ee” /ˈʃæloʊ ˈkɒpi/
A copy of an array or object where only the top layer is new. Any arrays or objects inside it are shared with the original, so changing them shows up in both.
What is Shallow Copy in JavaScript?
Shallow Copy — A new collection that still shares the items inside it with the original.
const order = { item: "tea", quantity: 1 };
const updatedOrder = { ...order, quantity: 2 };
In a sentence
- “My shallow copy of the pet had its own name, but its list of favorite toys was still the original list.”
Level: Freelancer · More JavaScript terms at this level
Updated