Created
October 31, 2011 14:15
-
-
Save jashkenas/1327580 to your computer and use it in GitHub Desktop.
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
// From: https://mail.mozilla.org/pipermail/es-discuss/2011-October/thread.html#17696 | |
const className = superClass <| function(/*constructor parameters */) { | |
//constructor body | |
super.constructor(/*arguments to super constructor */); | |
this.{ | |
//per instance property definitions | |
}; | |
}.prototype.{ | |
//instance properties defined on prototype | |
}.constructor.{ | |
//class (ie, constructor) properties | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@addyosmani: All of the various class libraries work more or less the same way, with different levels of extra features. Resig's simple inheritance is about as minimal as it gets, whereas JS.Class has all kind of extra hooks and goodies in it.
CoffeeScript's classes are just simple proper prototype chain inheritance, combined with sugar for easily calling super. The main bonus feature that isn't (and can't be) mimicked in a JavaScript library is executable class bodies.