爲什麼我的「C」條件轉到'else'語句?,他們分開去了'if'語句,但是一起工作。javascript if語句沒有按預期評估
var objTest = {
ID : "10"
};
//A: First Condition: Exist value in property ID
console.log((objTest.ID ? 'if' : 'else')); // output => "if"
//B: Second Condition: Value different from "0"
console.log((objTest.ID != "0" ? 'if' : 'else')); // output => "if"
//C: First and Second Condition together must be "if"
console.log((objTest.ID & objTest.ID != "0" ? 'if' : 'else')); // output => "else"
'&'和'&&' – Pointy
之間有很大的區別另外請注意,這裏並沒有包含真正的if語句。 – Pointy
你比我快 –