I’m working on a Javascript module that looks like that.
var myApp = (function(){
private function1();
private function2()
return {
publicMethod1:function(){}
publicMethod2:function(){}
publicMethod3:function(){}
}
})();
myApp.publicMethod3();
My module will maybe be used in a tag container, I’m not really sure about how that work but I’m afraid if for example, my module is executed in a global autoexecuted function, like this :
(function(){
var myApp = (function(){
private function1();
private function2()
return {
publicMethod1:function(){}
publicMethod2:function(){}
publicMethod3:function(){}
}
})();
myApp.publicMethod3();
})();
I can’t execute the methode of my module like I did before, my code won’t work inside.
So what I’m asking?
Do you know how work tag container?
And, if the tag container includes my code in a global auto executed function, how could I change my module’s code to make it working well inside.
Thanks for your answers, and if is not clear to you, I’m gonna answer quickly to your questions.
You just had a bunch of syntax errors in your code, try this:
There is no
privatekeyword in JavaScript, and functions have to be declared as:Also, items in objects are separated with a comma, like this: