Created
December 13, 2013 10:08
-
-
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+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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