just have 2 question regarding JS conditional operator, is the below 2 expression valid?
1.
if(isUser && isUser === true || isGuest && isGuest === true){
//...
}
I am wondering do I have to add () to make it like and still have the same functioning:
if((isUser && isUser === true) || (isGuest && isGuest === true)){
//...
}
const items = list.orderList && list.orderList.isUser === true || list.orderList.isGuest ? list.items : [];
I am wondering do I have to add () to make it like and functioning the same as above conditional operator:
const items = list.orderList && (list.orderList.isUser === true || list.orderList.isGuest === true) ? list.items : [];
&&and||as*and+. The&&operator binds more tightly than||.if (isUser || isGuest)(orif (isUser === true || isGuest === true)if the variables can hold non-boolean values, but you should avoid that). The expressions in #2 are not equivalent.false && false || truevsfalse && (false || true)in the console.