Skip to content

Instantly share code, notes, and snippets.

@goliatone
Created February 16, 2014 04:13
Show Gist options
  • Save goliatone/9029106 to your computer and use it in GitHub Desktop.
Save goliatone/9029106 to your computer and use it in GitHub Desktop.
Deep extend method
var extend = function extend(target) {
var sources = [].slice.call(arguments, 1);
sources.forEach(function (source) {
for (var property in source) {
if(source[property] && source[property].constructor &&
source[property].constructor === Object){
target[property] = target[property] || {};
target[property] = extend(target[property], source[property]);
} else target[property] = source[property];
}
});
return target;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment