Skip to content

Instantly share code, notes, and snippets.

@Colorfulstan
Created November 24, 2015 11:25
Show Gist options
  • Save Colorfulstan/a330cb2f86ea230b3ddf to your computer and use it in GitHub Desktop.
Save Colorfulstan/a330cb2f86ea230b3ddf to your computer and use it in GitHub Desktop.
var _mergeRecursive = function(obj1, obj2) {
//iterate over all the properties in the object which is being consumed
for (var p in obj2) {
// Property in destination object set; update its value.
if ( obj2.hasOwnProperty(p) && typeof obj1[p] !== "undefined" ) {
_mergeRecursive(obj1[p], obj2[p]);
} else {
//We don't have that level in the heirarchy so add it
obj1[p] = obj2[p];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment