"Count Seven" ?CEnglish Corner >>
<< Zero sum games
Extending JavaScript Objects

Author Zhou Renjian Create@ 2005-02-24 11:53
whizz Note icon
  JavaScript is not a true Object-Oriented system. JavaScript do not support the
same inheritance mechanism as Java. So I have to play trips on extending some
classes. For example:

Object.prototype.extendsSuperClass = function(superObject) {
    for (var s in superObject) {
        eval("this." + s + " = superObject." + s + ";");
    }
}
function LoadingRunnable(self, uri) {
    this.superClass = "Runnable";
    this.Class = "LoadingRunnable";
...
}
function LoadingXMLRunnable(self, uri) {
    this.extendsSuperClass(new LoadingRunnable(self, uri));
    this.Class = "LoadingXMLRunnable";
...
}
本记录所在类别:
本记录相关记录: