Skip to content

Instantly share code, notes, and snippets.

@danesparza
Created July 15, 2011 19:41
Show Gist options
  • Save danesparza/1085398 to your computer and use it in GitHub Desktop.
Save danesparza/1085398 to your computer and use it in GitHub Desktop.
More fun with Javascript - using deep copy
// 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