我要表达的逻辑是:
condition_1
和condition2
或condition3
和condition_4
然后console.log("THING ONE")
console.log("THING TWO");
编辑-在编写时发现原始问题在其他代码中,因此发布答案Q&A-style
答案 0 :(得分:-2)
是的,如果or
条件在括号中,则看起来可以,例如:
var logged_in = true;
var author_username = "fred";
var username = "fred";
var is_editor = false;
var is_something = true;
if (logged_in === true && (author_username === username || is_editor === true) && is_something === true) {
console.log("THING ONE");
} else {
console.log("THING TWO");
}
另请参阅:
How to specify multiple conditions in an if statement in javascript