Skip to content

Instantly share code, notes, and snippets.

@aweary
Created October 1, 2014 02:48
Show Gist options
  • Save aweary/cf982bee1f9fd4576992 to your computer and use it in GitHub Desktop.
Save aweary/cf982bee1f9fd4576992 to your computer and use it in GitHub Desktop.
Create extend() on all objects
Object.defineProperty(Object.prototype, 'extend', {
writable: true,
enumerable: false,
configurable: true,
value: function(o){
var names = Object.getOwnPropertyNames(o);
for(var i = 0; i < names.length; i++){
if(names[i] in this) continue;
var desc = Object.getOwnPropertyDescriptor(o, names[i]);
Object.defineProperty(this, names[i], desc)
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment