Closed TheFuzzy closed 10 years ago
Included in common.js:
common.js
sewi.inherits
sewi.constants
Note: to use inherits, sub-classes must still call the constructor of their superclass, e.g.:
inherits
function Oval() { this.x = 10; this.y = 20; } Oval.prototype.getArea() { return 30; } function Circle() { Oval.call(this); // calls superclass constructor this.x = 20; } sewi.inherits(Circle, Oval); // before declaring prototype functions Circle.prototype.getDiameter() { return 40; } var circle = new Circle(); circle.x == 20; // true circle.y == 20; // true circle.getArea() == 30; // true circle.getDiameter() == 40; // true circle instanceof Oval // true circle instanceof Circle // true
Included in
common.js
:sewi.inherits
- a helper function for class inheritance.sewi.constants
- a dictionary to store all constants, including "magic strings".Note: to use
inherits
, sub-classes must still call the constructor of their superclass, e.g.: