title: Encapsulation in javascript
body: <p>How to get <code>types.type1["color"]</code> from below? I mean how to write public method to get it.</p>
  
  <pre><code>Config = (function(){
  
  var ids = {
        id1: "id1",
        id2: "id2",
        ....
    }
  var types = {
         type1: {
                 "color": "red",
                 "size": "10"
                  ...
                },
          type2: {
                 "color": "red",
                 "size": "40"
              }
        }
    return {
        getIds: function(id){
              return ids[id];
         }
        getTypes: function(type){
               return types[type];
         }
  
   }
  }();
  </code></pre>