Skip to content

Instantly share code, notes, and snippets.

@tancredi
Last active January 2, 2016 09:59
Show Gist options
  • Save tancredi/8286556 to your computer and use it in GitHub Desktop.
Save tancredi/8286556 to your computer and use it in GitHub Desktop.
Quick, stand-alone deep extend implementation
function extend () {
var out = arguments[0],
i, key, obj, val;
for (i = 1; i < arguments.length; i += 1) {
obj = arguments[i];
for (key in obj) {
if (obj.hasOwnProperty(key)) {
val = obj[key];
if (val && typeof val === 'object' && !val.length) {
out[key] = extend({}, val);
} else {
out[key] = val;
}
}
}
}
return out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment