:: Forum >>

ActiveWidgets Code object.js

Hello, I was going through some of the code and I have a question regarding the code. The code in object.js is as follows.
.
.
.
Active.System.Object.subclass = function(){
var constructor = function(){this.init()};
for (var i in this) {constructor[i] = this[i]}
constructor.prototype = new this();
.
.
.
My quesiton is this. In the for loop in the above code the properties of the 'this' object which is Active.System.Object in this case are copied into the constructor objects. So in essence the constructor object is now a subclass of the Active.System.Object. This was what we wanted to do and we did that. Great. So why do you then need the last line constructor.prototype = new this();
If this creates the inheritence chain then why did we copy the properties and methods in the for loop? Why do we need both the copying and the constructor.prototype = new this(); ? Why not one?

Thank you..
Regards..


Raj
Wednesday, December 28, 2005

This topic is archived.


Back to support forum

Forum search