title: optimize switch code to function args call
body: <p>Im using the following code that working OK.</p>
  
  <pre><code>  _handleIn: function(Filecontent, config) {
              var oExtendedHTML = Filecontent;
              switch (config.action) {
                  case 'new':
                      oExtended = this._crElement(Filecontent, config);
                      break;
                  case 'upd':
                      oExtended = this._updlement(oExtended, config);
                      break;
              }
              return oExtended;
          },
  </code></pre>
  
  <p>Since I new to JS and I want to learn more I read that the switch sometimes can be change to this pseudo coe:</p>
  
  <p>This</p>
  
  <pre><code>function actions(key, args){
    switch(key){ 
      case: 'foo':
        return doFoo(args);
        break;
      case: 'bar':
        return doBar(args);
        break;
      case: 'baz':
        return doBaz(args);
        break
    }
  }
  
  var value = actions(keyargs);
  
  // To This
  
  
  
   var actions = {
        foo: function doFoo(){...},
        bar: function doBar(){...},
        baz: function doBaz(){...}
      };
  
      var value = actions[key](args);.
  </code></pre>
  
  <p>my question is how can I change my code to this? not sure how to pass the key and args, Im using requirejs AMD module.</p>