2015-01-04 55 views
-3

什麼邏輯運算符會返回以下結果?邏輯運算符只有在兩個語句都是false的情況下才會返回false?

If A is true, and B is false, return True 
If A is true, and B is True, return True 
If A is false and B is true, return True 
If A is false and B is false return false 
+3

'if(A || B){...}' – 2015-01-04 14:26:53

+0

這應該是非常容易弄清楚的 - > ** http://jsfiddle.net/8y7xjfqk/** – adeneo 2015-01-04 14:28:41

+0

基本邏輯。這是一個合乎邏輯的OR。 – lurker 2015-01-04 14:32:43

回答

0

您需要OR運算符,在被稱爲logical disjunction

在大多數編程語言邏輯它可以是一個文字(or)或符號這樣的:

|| 

所以(在JavaScript ),你需要

A || B 

這裏有一個真值表:

A | B | A or B 
0 | 0 | 0 
0 | 1 | 1 
1 | 0 | 1 
1 | 1 | 1 
0

邏輯OR運算符 - 在JavaScript中,這是||運算符。

相關問題