molily: Namespacing

Beitrag lesen

Hallo,

Ich verstehe dein Problem nicht.

Namespace = {};  
Namespace.Konstruktur = function (variable) {  
  this.variable = variable;  
  this.methode = function () {  
       alert('method');  
  };  
};  
var obj = new Namespace.Konstruktur('abc');  
obj.methode();

Wenn ich hier
Namespace.methode();
mache, dann gibts die Methode natürlich nicht.

Und was Namespace.variable angeht:
Namespace ist ein einfaches Object-Objekt, man kann ihm willkürlich Eigenschaften hinzufügen. Das hat aber keine negativen Auswirkungen, was ist daran schlimm? Vor allem hat Namespace.variable nichts mit obj.variable zu tun.

Mathias