title: How to create javascript function lookup object?
body: <p>I'm attempting to create a function lookup in Javascript essentially mapping a data type to a function that does something for that data type. Right now I have something similar to:</p>
  
  <pre><code>var Namespace = Namespace || {};
  Namespace.MyObj = function () {
      var stringFunc = function(someData) {
          //Do some string stuff with someData
      };
  
      var intFunc = function(someData) {
          //Do some int stuff with someData
      };
  
      var myLookUp = {
          'string': stringFunc,
          'int' : intFunc
      };
  
      return {
           PublicMethod: function (dataType, someData) {
               myLookUp[dataType](someData);
           }
      };
  } ();
  </code></pre>
  
  <p>When I invoke <code>Namespace.MyObj.PublicMethod(dataType, someData)</code> I get an error that myLookUp is not defined. I'm assuming I'm not going about setting up the function lookup object correctly, but not sure how to do so. Thanks for any help.</p>