Skip to content

Instantly share code, notes, and snippets.

@robozevel
Forked from livingston/ES5 Extend & Clone Objects.js
Last active December 24, 2015 07:29
Show Gist options
  • Save robozevel/6764307 to your computer and use it in GitHub Desktop.
Save robozevel/6764307 to your computer and use it in GitHub Desktop.
ES5 Object.extend
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