hi tami,
hi ichbinich,
Hallo,
var myfunc = (function() {
[...]
return {
publicMethod: function() {
}
};}());
> >
> >
> > Mit `myfunc.publicMethod()`{:.language-javascript} kann ich nun die öffentliche Methode aufrufen.
> >
>
> > Wie kann ich die Methode direkt aufrufen, also ohne die anonyme Funktion in einer Variable zu speichern?
>
> Du speicherst nicht die Funktion in einer Variable. Du erhälst ein Objekt {} mit dieser Methode von der Funktion.
s.a.
~~~javascript
/*jslint browser: false, devel: true */
(function () {
"use strict";
return {
myMethod: function () {
alert("hallo");
}
};
}()).myMethod();
mfg
tami