Classical inheritance for constructors.
<script src="inherit.js"></script>
npm install https://gist.github.com/abernier/decf360c677a54aa415c/download
var inherit = require('inherit');
function A() {}
A.prototype.foo = function () {};
function B() {
B.uber.constructor.apply(this, arguments);
}
inherit(B, A);
B.prototype.foo = function () {
this.constructor.uber.foo.apply(this, arguments);
}
NB:
B.uber
references toA.prototype
- classically, you can access the ctor from prototype's methods thanks to
constructor
property.
http://bl.ocks.org/abernier/decf360c677a54aa415c