I was just playing with som javascript OOP, just for fun, but I get an error...
I'm trying to create classes i a class, and don't know if it's posible..
Can anyone get me on the right way ...
See my problem here: http://jsfiddle.net/wBZ4r/2/
function MyClass() {
var server;
this.__init__ = function() {
this.server = new this.Server();
console.log(this.server.url);
}();
/* -------- Server Class ------------------ */
this.Server = function() {
var url;
this.__init__ = function() {
this.url = "server/test.json";
}();
this.connect = function() {
console.log(this.url);
};
};
}(window.myclass = new MyClass());
Got this error: "this.Server is not a constructor"
Hope it makes sense!
this.Serverbefore it's defined.