The juxtaposition of conditions?

if(condition == "con1" || condition == "con2")

cannot be written as

if(condition == "con1" || "con2")

?

Mar.01,2021

No, this problem is designed to JS operator priority.

if(condition == "con1" || condition == "con2")

is equivalent to:

if((condition == "con1") || (condition == "con2"))

and if (condition = = "con1" | | "con2")

is equivalent to:

if((condition == "con1") || "con2")


"con1" | | "con2": "con1" is a string, equivalent to true, so "con1" | | "con2" = = "con1"
if (condition = = "con1" | | "con2") you just judged condition = = "con1"


No, priority question
is equivalent to

if((condition == "con1") || ("con2"))

you can't be the first to return con2 after false, and then true forever.
write your own filter

.
Menu