Skip to content

Instantly share code, notes, and snippets.

@toddmotto
Last active August 29, 2015 14:03
Show Gist options
  • Save toddmotto/ef46e3075b6a8ba70cb0 to your computer and use it in GitHub Desktop.
Save toddmotto/ef46e3075b6a8ba70cb0 to your computer and use it in GitHub Desktop.
ECMAScript 5 extend(), preserves original Object values
function extend (target, source) {
target = JSON.parse(JSON.stringify(target));
Object.keys(source).map(function (prop) {
Object.prototype.hasOwnProperty.call(target, prop) && (target[prop] = source[prop]);
});
return target;
};
@toddmotto
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment