Last active
February 17, 2018 02:05
-
-
Save jhnlsn/5410328221720a724aef65e34b7e9a10 to your computer and use it in GitHub Desktop.
deep clone doesn't work
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 a = [1,2,3,4,5]; | |
const aCloned = [...a]; | |
aCloned.push(7); | |
console.log(a); | |
console.log(aCloned); | |
ref = {big: 'name'}; | |
skills = ["javascript"] | |
const o = { name: "john", lastname: "nelson", skills: skills, total: {first: ref} }; | |
const oCloned = { ...o }; | |
ref.big = "what" | |
o.skills.push('php') | |
oCloned.rancher = true; | |
console.log(o); | |
console.log(oCloned); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment