If I want to set the prototype I need to do this always outside of the function/object. I want to do that with this.prototype...
example:
MyPrototype = function() {
this.name = "MyPrototype";
this.number = 3;
}
MyObjectToExtend = function() {
this.prototype = new MyPrototype(); //<-- I want this
this.name = "MyObjectToExtend";
}
o = new MyObjectToExtend();
If i want to get o.number
i will get nothing. But it is possible to access it with o.prototype.numer
but I don't think that this is how you should get it, because the bellow example is working fine...
MyPrototype = function() {
this.name = "MyPrototype";
this.number = 3;
}
MyObjectToExtend = function() {
this.name = "MyObjectToExtend";
}
MyObjectToExtend.prototype = new MyPrototype(); //<-- I don't want this
o = new MyObjectToExtend();
Now i can access o.number
and it will give me 3
as it should be.
But I don't want this, I want to set the prototype as in the top example...