Skip to content

Instantly share code, notes, and snippets.

@slikts
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slikts/11053697 to your computer and use it in GitHub Desktop.
Save slikts/11053697 to your computer and use it in GitHub Desktop.
Naive extend objects & primitives only
function extend(target, source) {
Object.keys(source).forEach(function(key) {
var sourceItem = source[key];
var targetItem = target[key];
if (sourceItem instanceof Object && targetItem !== undefined) {
extend(targetItem, sourceItem);
} else {
target[key] = sourceItem;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment