Unable to call `Rect` constructor

by Andreas Renberg

JavaScript

Rect.prototype.containsPoint = function(x, y) {
    // Clever "use" or "abuse" of `switch`?
    switch (true) {
        case (x < this.x):
        case (x > this.x + this.width):
        case (y < this.y):
        case (y > this.y + this.height):
            return false;
        default: 
            return true;
    }
}

// TypeError: Illegal constructor
var hitBox = new Rect(20, 20, 100, 100);

// TypeError: Illegal constructor
//var hitBox = new Rect();
//hitBox.setRect(20, 20, 100, 100);

console.log(hitBox.containsPoint(50, 50));