我負責一個JavaScript web應用程序。這是非常複雜的,而且我遇到一些麻煩語法:Javascript變量聲明語法
getThemeBaseUrl = function() {
var customConfigPath = "./customer-configuration";
if (parseQueryString().CustomConfigPath) {
customConfigPath = parseQueryString().CustomConfigPath;
}
var clientId = parseQueryString().ClientId;
return customConfigPath + "/themes/" + clientId;
};
parseQueryString = function() {
var result = {}, queryString = location.search.substring(1), re = /([^&=]+)=([^&]*)/g, m;
while (m = re.exec(queryString)) {
result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
return result;
};
特別
parseQueryString().CustomConfigPath
和var result = {}, queryString = location.search.substring(1), re = /([^&=]+)=([^&]*)/g, m;
第一似乎是一種由parseQueryString功能屬性訪問。
第二個看起來是數組聲明,但沒有Array()構造函數。此外,m
值在while循環中沒有推測的數組結果時被調用。