Skip to content

Instantly share code, notes, and snippets.

@zapthedingbat
Created December 13, 2013 10:08
Show Gist options
  • Save zapthedingbat/7942276 to your computer and use it in GitHub Desktop.
Save zapthedingbat/7942276 to your computer and use it in GitHub Desktop.
Extend method copies properties from one object to another. Requires JavaScript 1.8.5+
Object.extend = function(toObj, fromObj){
var p = Object.getOwnPropertyNames(fromObj),
i = p.length;
while(i--)
{
Object.defineProperty(toObj, p[i], Object.getOwnPropertyDescriptor(fromObj, p[i]));
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment