I would have to see a bit more of your code. As a side note, you don't want to use uppercased variables that aren't constructors (upper camel case) or constants (all capped). In any case here's a little demo on how to use OOP in JS.
Code:
function Square(w, h) {
this.width = w;
this.height = h;
}
Square.prototype.calcArea = function() {
return this.width * this.height;
};
Square.prototype.calcPerimiter = function() {
return 2 * (this.width + this.height);
};
Square.prototype.compareTo = function(square) {
var a = this.calcArea();
var b = square.calcArea();
if(a < b)
return -1;
if(a > b)
return 1;
return 0;
};
var sq1 = new Square(2, 5);
var sq2 = new Square(1, 1);
alert(sq1.compareTo(sq2));
Bookmarks