Skip to content

Instantly share code, notes, and snippets.

@tobie
Created January 7, 2009 15:56
Show Gist options
  • Save tobie/44308 to your computer and use it in GitHub Desktop.
Save tobie/44308 to your computer and use it in GitHub Desktop.
Object.extend = Object.extend.wrap(function(proceed, destination, source, safe) {
if (!safe) return proceed(destination, source);
for (var property in source) {
if (!(property in destination))
destination[property] = source[property];
}
return destination;
});
Object.extend({foo: 123}, {foo: 456}, true).foo
// -> 123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment