Last active
August 24, 2022 18:44
-
-
Save rafaelmaeuer/77a883bfbb14f1c27044644ad8cf48f7 to your computer and use it in GitHub Desktop.
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
// Shallow Copy (with reference) | |
var objectIsNew = objectIsOld; | |
// Name will change in both objects | |
objectIsNew.name = 'NameChanged'; | |
// Deep Copy e.g. with JSON functions | |
var objectIsNew = JSON.parse(JSON.stringify(objectIsOld)); | |
// Name will only change in new object | |
objectIsNew.name = 'NameChanged'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment