Skip to content

Instantly share code, notes, and snippets.

@nonkr
Last active December 21, 2015 12:08
Show Gist options
  • Save nonkr/6303366 to your computer and use it in GitHub Desktop.
Save nonkr/6303366 to your computer and use it in GitHub Desktop.
Javascript Object deepExtend
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;
};
var dstObj = Object.deepExtend({name:'jason'}, {age:18});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment