オプション 1 - オブジェクト内で複数の結果を返す
var initKeyValues = function () {
var petKeys = $('#pets input:checked').map(function () {
return $(this).val();
}).get().join('+');
var employeeKey = $('#employee input:checked').map(function () { return $(this).val(); }).get().join('+');}
return {"petKeys": petKeys, "employeeKey": employeeKey}
};
var whenSelectDateFromCalendar = function () {
var result = initKeyValues();
petKeys = result.petKeys;
employeeKey = result.employeeKey;
// or even...
petKeys = result["petKeys"];
employeeKey = result["employeeKey"];
};
オプション 2: 配列内で複数の結果を返す
var initKeyValues = function () {
var petKeys = $('#pets input:checked').map(function () {
return $(this).val();
}).get().join('+');
var employeeKey = $('#employee input:checked').map(function () { return $(this).val(); }).get().join('+');}
return [petKeys, employeeKey];
};
var whenSelectDateFromCalendar = function () {
var result = initKeyValues();
petKeys = result[0];
employeeKey = result[1];
};