,

javascript コマンドパターン

http://www.addyosmani.com/resources/essentialjsdesignpatterns/book/#commandpatternjavascript

$(function(){
	
	var CarManager = {
	
		  /* request information */
		  requestInfo: function(model, id){
		    return 'The information for ' + model + ' with ID ' + id + ' is foobar';
		  },
		  
		  /* purchase the car */
		  buyVehicle: function(model, id){
		  	return 'You have successfully purchased Item ' + id + ', a ' + model;
		  },
		  
		  /* arrange a viewing */
		  arrangeViewing: function(model, id){
		  	return 'You have successfully booked a viewing of ' + model + ' ( ' + id + ' ) ';
		  }
	  
	  };
	  
})();
  
CarManager.execute = function(command){
  return CarManager[command.request](command.model,command.carID);
};
Our final sample calls would thus look as follows:

CarManager.execute({request: "arrangeViewing", model: 'Ferrari', carID: '145523'});  
CarManager.execute({request: "requestInfo", model: 'Ford Mondeo', carID: '543434'});	
CarManager.execute({request: "requestInfo", model: 'Ford Escort', carID: '543434'});	
CarManager.execute({request: "buyVehicle", model: 'Ford Escort', carID: '543434'});

evalばいいって話もありますが、一寸堅牢ですね