Last active
March 10, 2017 01:27
-
-
Save TravisMullen/a74fcd9b22ce5152228a to your computer and use it in GitHub Desktop.
Deep Extend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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