http://wiki.ecmascript.org/doku.php?id=harmony:object_extension_literal_class_pattern
I like the Class Definition Pattern and tried to make it more flexible:
const className = superClass <| function(/*constructor parameters */) {
//constructor body
super.constructor(/*arguments to super constructor */);
this.{
//per instance property definitions
};
}.withPrototype({
//instance properties defined on prototype
}).withProperties({
//class (ie, constructor) properties
});
- Approach: Define two methods Function.prototype.withPrototype() and
Function.prototype.withProperties(). The latter task could also be performed
via the object extension operator – I used a method for reasons of symmetry.
Both methods return "this".
- Advantages compared to using the object extension operator:
- Can omit the class property definition (without having to append
".constructor").
- Both “clauses” can be swapped.
--
Dr. Axel Rauschmayer
[email protected]
twitter.com/rauschma
home: rauschma.de
blog: 2ality.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss