title: How To Call Function from Dictionary in javascript
body: <p>I'm just playing around building an API_Routing system that will let me build class focused modules for an API, I'm not necessarily aiming for industry best practices and am just fleshing out ideas on how to build things in javascript for curiosity.</p>
  
  <p>I have a ServerManager class that when the server is run handles all of the processing, this class uses the API_Router class I developed to process the URL that was provided and pass the request to the proper module for handling.</p>
  
  <p>Currently the URL I am using is 
  <a href="http://localhost:8080/user/add/23123/" rel="nofollow noreferrer">http://localhost:8080/user/add/23123/</a></p>
  
  <p>/user/ 
  This tells my program that I am intending on accessing the User Module.</p>
  
  <p>Each Module is able to define, both submodules or functions inside of the routeMapping function.</p>
  
  <p>I have am attaching my User.js file that handles the User Module.</p>
  
  <pre><code>var http = require('http');
  
  
  //#File: UserManager.js
  ///http://localhost:8080/user/23123/
  ///http://localhost:8080/user/add/23123/
  var UserManager = {};
  
  
  UserManager.Create = function() {  
      var UserAcc = {
          "Username": "test123",
          "FirstName": "cody",
          "LastName": "jones",
          "Id": "000001"
      };
  
      return UserAcc;
  }
  
  UserManager.route = function(){
      return 'user';
  }
  
  UserManager.routeMapping = {
      "add": this.Create
  }
  
  UserManager.Run = function(Data){
      var runMe = Data[0];
      console.log(this.routeMapping);
      console.log(this.routeMapping[runMe]);
  
  }
  
  
  UserManager.hasSubmodule = false;
  
  
  module.exports = UserManager;
  </code></pre>
  
  <p>I am trying to build the routeMapping function to correlate to all of the functions I build for my API, so I need to ensure that the proper function is called based off the URL.</p>
  
  <pre><code>UserManager.routeMapping = {
          "add": this.Create    //What am I doing wrong here
      }
  
  UserManager.Run = function(Data){
      var runMe = Data[0];//This will resolve to a string "add"
      this.routeMapping[runMe]();//This should run the function stored in the routemapping
  
  }
  </code></pre>