JavaScript inheritance with helper constructor
Is something wrong with this?:
http://jsbin.com/ewatit/37/edit
http://jsperf.com/js-inheritance-performance/40
var A = function(input) {
this.factory = function(childClass) {
childClass.prototype = this;
return new childClass(this);
};
};
var B = function(parent) { };
B.inherit = function(input) {
return new A(input).factory(B);
}
var objA = new A();
var objB = new B.inherit();
No comments:
Post a Comment