gpt4 book ai didi

javascript if语句未按预期评估

转载 作者:行者123 更新时间:2023-11-29 20:59:42 24 4
gpt4 key购买 nike

<分区>

为什么我的“C”条件会转到“else”语句?它们分开后会转到“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"

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com