Created
May 16, 2019 16:01
-
-
Save josephdicdican/b16abef39774c27ef82cfcdcb4c90132 to your computer and use it in GitHub Desktop.
Javascript Shallow & Deep Copy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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