Extending JavaScript Objects
Author
Zhou Renjian
Create@
2005-02-24 11:53
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";
...
}