Forked from livingston/ES5 Extend & Clone Objects.js
Last active
December 24, 2015 07:29
-
-
Save robozevel/6764307 to your computer and use it in GitHub Desktop.
ES5 Object.extend
This file contains hidden or 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.defineProperty(Object, "extend", { | |
enumerable: false, | |
value: function extend(obj) { | |
Array.prototype.slice.call(arguments, 1).forEach(function(current) { | |
Object.getOwnPropertyNames(current).forEach(function(key) { | |
Object.defineProperty(obj, key, Object.getOwnPropertyDescriptor(current, key)); | |
}); | |
}); | |
return obj; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment