Skip to content

Instantly share code, notes, and snippets.

@josephdicdican
Created May 16, 2019 16:01
Show Gist options
  • Save josephdicdican/b16abef39774c27ef82cfcdcb4c90132 to your computer and use it in GitHub Desktop.
Save josephdicdican/b16abef39774c27ef82cfcdcb4c90132 to your computer and use it in GitHub Desktop.
Javascript Shallow & Deep Copy
const combo_meal = {
rice: 1,
fried_chicken: 1,
drink: 1
};
let order1 = combo_meal;
// order1.drink = 0;
let order2 = {...combo_meal};
order2.drink = 0;
console.log("menu:", combo_meal);
console.log("order:", order2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment