Skip to content

Instantly share code, notes, and snippets.

@queckezz
Last active December 19, 2015 10:59
Show Gist options
  • Save queckezz/5944435 to your computer and use it in GitHub Desktop.
Save queckezz/5944435 to your computer and use it in GitHub Desktop.
Object.extend()
Object.defineProperty(Object.prototype, 'extend', {
enumerable: false,
value: function( from ) {
Object.getOwnPropertyNames( from ).forEach(function( name ) {
if ( name in this ) {
Object.defineProperty( this, name, Object.getOwnPropertyDescriptor( from, name ));
}
});
return this;
}
});
/*
* Usage
*/
obj.extend( obj2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment