我對JavaScript並不擅長。我正在嘗試編寫一個可用於即時設置設置的構建配置類。這個想法是通過它要運行的環境,然後正確設置變量。我有以下幾種:我該如何改進我的Javascript構建配置類?
function BuildConfig(){
this.build = 'html5';
this.server = 'http://someurl',
this.nfc = true,
this.barcode = true,
this.scheduler = true,
this.getConfig = function(buildType){
switch(buildType)
{
case "ios":
this.build = 'ios';
this.server = 'http://someurl';
this.nfc = true;
this.barcode = false;
this.scheduler = false;
break;
case "android":
this.build = 'android';
this.server = 'http://someurl';
this.nfc = false;
this.barcode = true;
this.scheduler = false;
break;
case "websiteanonymous":
this.build = 'websiteanonymous';
this.server = 'http://someurl';
this.nfc = true;
this.barcode = false;
this.scheduler = true;
break;
case "website":
this.build = 'website';
this.server = 'http://someurl';
this.nfc = true;
this.barcode = true;
this.scheduler = false;
break;
default:
}
};
};
這看起來好嗎?可以進行任何改進嗎?
感謝
您可能想要在http://codereview.stackexchange.com/中發佈此內容 – ajax333221