Created
November 2, 2013 22:39
-
-
Save wkronemeijer/7284266 to your computer and use it in GitHub Desktop.
extend arbitrary classes with your prepoerties; this works just like the Backbone.js variant, but is now situated under Object.
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.defineProperty(Object.prototype, 'extend', {value: function (proto_props) { | |
var child = proto_props.hasOwnProperty('constructor') ? | |
proto_props.constructor : | |
function () {child.__super__.constructor.apply(this, arguments);}; | |
child.prototype = Object.create(this.prototype); | |
child.prototype.constructor = child; | |
Object.keys(proto_props).forEach(function (key) { | |
child.prototype[key] = proto_props[key]; | |
}); | |
child.__super__ = this.prototype; | |
return child; | |
}}); //snatched from backbone.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment