JavaScript:逻辑运算符“A && B”的反义词是什么?
JavaScript: What is the opposite of the logical operator `A && B`?
在下面的代码中,条件 (ran1 <= 63 && ran2 <= 18)
的反义词是什么,它应该适合 if
语句的 else
部分?
是(ran1 <= 63 || ran2 <= 18)
和(! (ran1 <= 63 && ran2 <= 18))
吗?
从逻辑上讲,我认为 A and B
的反义词是 A or B
和 neither A nor B
。但是我不确定如何在 JavaScript.
中表达 neither A nor B
位
var ran1 = 1 + Math.floor(Math.random() * 100);
var ran2 = 1 + Math.floor(Math.random() * 100);
if (ran1 <= 63 && ran2 <= 18) {
// code
} else {
// code
}
A && B
的数学否定是 !A || !B
,所以在你的情况下,它将是
ran1 > 63 || ran2 > 18
在下面的代码中,条件 (ran1 <= 63 && ran2 <= 18)
的反义词是什么,它应该适合 if
语句的 else
部分?
是(ran1 <= 63 || ran2 <= 18)
和(! (ran1 <= 63 && ran2 <= 18))
吗?
从逻辑上讲,我认为 A and B
的反义词是 A or B
和 neither A nor B
。但是我不确定如何在 JavaScript.
neither A nor B
位
var ran1 = 1 + Math.floor(Math.random() * 100);
var ran2 = 1 + Math.floor(Math.random() * 100);
if (ran1 <= 63 && ran2 <= 18) {
// code
} else {
// code
}
A && B
的数学否定是 !A || !B
,所以在你的情况下,它将是
ran1 > 63 || ran2 > 18