I need to extend an abstract class in javascript. I've buy the Javascript The Definitive Guide - O'Reilly there are some examples of OOP in js. I've tried to execute one of the example to extends an abstract class, but i receive the "AbstractSet.extend is not a function". Can someone help me to understand the problem? Thanks
function abstractmethod() { throw new Error("abstract method"); }
function AbstractSet() { throw new Error("Can't instantiate abstract classes");}
AbstractSet.prototype.contains = abstractmethod;
var NotSet = AbstractSet.extend(
function NotSet(set) { this.set = set; },
{
contains: function(x) { return !this.set.contains(x); },
toString: function(x) { return "~" + this.set.toString(); },
equals: function(that) {
return that instanceof NotSet && this.set.equals(that.set);
}
}
);
--- Firebug console AbstractSet.extend is not a function equals: function(that) {