Created
July 15, 2011 19:41
-
-
Save danesparza/1085398 to your computer and use it in GitHub Desktop.
More fun with Javascript - using deep copy
This file contains hidden or 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
| // First object, with a simple string property | |
| args1 = {}; | |
| args1.test1 = "blah"; | |
| // Second object, deep copied from the first | |
| args3 = $.extend(true, {}, args1) | |
| // As you might expect... | |
| // args3.test1 is "blah" | |
| // Set the property to something different | |
| // on the second object | |
| args3.test1 = "boo!"; | |
| // The objects are not linked | |
| // args1.test1 is "blah" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment