我有以下幾點:如何從javascript函數返回兩個參數?
function getPk(entity) {
var store = window.localStorage;
switch (entity) {
case "City":
if (store.getItem('AccountID')) {
// Need to return both of the below pieces of information
return store.getItem('AccountID') + "04" + "000";
return "CityTable";
} else {
paramOnFailure("Please reselect");
return false;
}
break;
的問題是我需要能夠調用這個函數,返回兩個字符串。在這裏,我顯示了兩個返回語句,但我知道我不能這樣做。
是否有一個乾淨的方式我可以返回兩個字符串到調用我的getPk(實體)函數的函數?
如果可能的話,你還可以舉一個例子說明如何閱讀返回的內容。
對不起,但我該如何讀取數組?你能給一個調用函數的例子和返回的例子嗎?提前致謝。 –
當然。看看https://gist.github.com/dc0fb7f77e74e0227d29 – x1a4