我是 Javascript 的完全新手,并且尝试了布尔表达式的所有可能组合,我留下了以下代码。为什么以下 JS 布尔逻辑对于除有效日期选择=真和通过日期选择=假以外的所有内容都失败
// initialisation
var effectiveDateSelected = new Boolean(false);
var throughDateSelected = new Boolean(false);
// values read in from web page
effectiveDateSelected = ...
throughDateSelected = ...
// the logical expression
if ((effectiveDateSelected) && !(throughDateSelected)) {
reportNum = 1;
alert("1 reportNum=" + reportNum);
}
if (!(effectedDateSelected) && (throughDateSelected)) {
reportNum = 2;
alert("2 reportNum=" + reportNum);
}
if (((effectedDateSelected) && (throughDateSelected)) ||
(!(effectedDateSelected) && !(throughDateSelected))) {
reportNum = 3;
alert("3 reportNum=" + reportNum);
}