My code is going to turn into a mess if I don't start using some sort of namespacing technique. I'm relatively new to programming large javascript projects but have significant experience with systems programming in C++/java/python etc.
Basically I'm trying to identify which is the preferred method for creating javascript namespaces, and what the pros/cons are for each method.
For example I could use either of the following three methods:
var proj.lib.layout = {
  "centreElem":     
  function (elem, W, H){
  },
  "getAbsolutePosition":
  function (elem){
  }
};
OR
var proj.lib.layout = {};
(function(){
  var l = proj.lib.layout;
  l.centreElem = function (elem, winW, winH){
    ..
  }
  l.getAbsolutePosition = function (elem){
    ..
  }
})();
OR
var proj.lib.layout = new function(){
  function centreElem(elem, W, H){
    ..
  }
  function getAbsolutePosition(elem){
    ..
  }
  this.centreElem          = centreElem;
  this.getAbsolutePosition = getAbsolutePosition;
} ();
There are other ways to do it too obviously, but these were the first that I've seen and thought of. Can anyone say there is a "best" technique, or at least point me towards some pros/cons from which I can evaluate which is best for me?
 
     
     
     
     
    