我是JavaScript新手,很抱歉,我不太瞭解。我有以下幾點,我想簡化一下。任何建議,將不勝感激。可以簡化此JavaScript嗎?
if (entity == "house") {
primaryKey = store.getItem('accountID') + "02" + "00";
table = "Content";
}
if (entity == "street") {
primaryKey = store.getItem('accountID') + "0000";
table = "Content";
}
if (entity == "city") {
var primaryKey = store.getItem('categoryID');
table = "Reference";
}
if (entity == "location") {
primaryKey = "0001" + store.getItem('examID');
table = "Content";
}
使用像這樣的開關命令http://www.w3schools.com/js/js_switch.asp – devtut 2012-04-11 05:58:13