Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Helper function to 'extend' prototypes
- var __extends = this.__extends || function (d, b) {
- function __() { this.constructor = d; }
- __.prototype = b.prototype;
- d.prototype = new __();
- };
- //Base class with a single function defined
- var BaseClass = (function () {
- function BaseClass() { }
- BaseClass.prototype.calc = function (x, y) {
- };
- return BaseClass;
- })();
- //Child class with the function overwritten.
- //It calls the base class function in the
- //context of 'this', so the base class
- //function can actually access members of
- //the child class when called.
- var ChildClass = (function (_super) {
- __extends(ChildClass, _super);
- function ChildClass() {
- _super.apply(this, arguments);
- }
- ChildClass.prototype.calc = function (x, y) {
- var z = _super.prototype.calc.call(this, x, y);
- };
- return ChildClass;
- })(BaseClass); //Notice the base class 'inheritance'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement