Skip to content

Instantly share code, notes, and snippets.

@TravisMullen
Last active March 10, 2017 01:27
Show Gist options
  • Save TravisMullen/a74fcd9b22ce5152228a to your computer and use it in GitHub Desktop.
Save TravisMullen/a74fcd9b22ce5152228a to your computer and use it in GitHub Desktop.
Deep Extend
var deepExtend = function(out) {
out = out || {};
for (var i = 1; i < arguments.length; i++) {
var obj = arguments[i];
if (!obj)
continue;
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
if (typeof obj[key] === 'object')
out[key] = deepExtend(out[key], obj[key]);
else
out[key] = obj[key];
}
}
}
return out;
};
deepExtend({}, objA, objB);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment