blackhydrogen / noop-sewi

Sana Encounter Web Interface (SEWI)
0 stars 1 forks source link

Added common code file #16

Closed TheFuzzy closed 10 years ago

TheFuzzy commented 10 years ago

Included in common.js:

Note: to use inherits, sub-classes must still call the constructor of their superclass, e.g.:

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