js设计模式7 Command Pattern

var CarManager = {
  			"requestInfo":function(model,id){
  				return "the infomation for "+model+" with id "+id+" is foo";
  				},
  			"buyVehicle":function(model,id){
  				return "you have successfully purchased "+id+" ,a "+model;
  				},
  			"arrangeViewing":function(){
  				return "you have successfully booked a view of "+model+"("+id+")";
  				}
  			};
  			//alert(CarManager);
  		CarManager.execute = function(name){
  			return CarManager[name] && CarManager[name].apply(CarManager,[].slice.call(arguments,1));
  			}
  		var info = CarManager.execute("requestInfo","myId","yModle");
  		alert(info);

你可能感兴趣的:(js设计模式7 Command Pattern)