Skip to content

Instantly share code, notes, and snippets.

@lovemyliwu
Created November 19, 2015 10:26
Show Gist options
  • Save lovemyliwu/1117e03245d9d7db6f75 to your computer and use it in GitHub Desktop.
Save lovemyliwu/1117e03245d9d7db6f75 to your computer and use it in GitHub Desktop.
JavaScript Object Extend
Object.deepExtend = function(destination, source) {
for (var property in source) {
if (source[property] && source[property].constructor &&
source[property].constructor === Object) {
destination[property] = destination[property] || {};
arguments.callee(destination[property], source[property]);
} else {
destination[property] = source[property];
}
}
return destination;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment