My main goal is to expertly organize my javascript code by eliminating any global elements. I came across two namespace declaration methods in this informative post, and now I'm looking for your input on the advantages and disadvantages of each.
var namespace1 = new function () {
var internalFunction = function () {
};
this.publicFunction = function () {
};
};
var namespace2 = {
publicFunction: function () {
}
};
In addition, can anyone advise me on how to create a private function within the 'namespace2' method?