Hmm, question 1: Does Twine2 use the conditionals as JavaScript?
question 2:
if the AND operator has a higher precedence, wouldn’t it be like that: $Var1 && Var4 && ($Var2 || $Var3)?
Var1 is grouped with Var4 and either Var2 or Var3.
I cannot validate question1 now (typing on phonr) but I think Sugarcube is likely to work as JS in this respect.
As for question2, order is always significant. Operator precedence has the effect of implied parentheses but it won’t move your operands. I auggest using parentheses in complex expressions, even if they are not required.
SugarCube tries to act as a thin abstract layer over standard JavaScript, so in the case of Operator Precedence it follows the standard JavaScript rules.
note: SugarCube includes a number of keyword based equivalents (to, and, or, not, etc…) for some of the standard JavaScript operators (===, &&, ||, !, etc…). These keywords are automatically converted into their JavaScript equivalents before the expression gets evaluated. So the precedence of those keyword based operators is the same as the JavaScript ones they represent.
So if the conditional expression being evaluated was…
<<if $Var1 && $Var2 || $Var3 && $Var4>>
…the logical AND&& has a ranking of 4 in the table linked to earlier, and the logical OR|| has a ranking of 3, where the higher the ranking the earlier the operator is applied. This means that the && join will be evaluated before the || join is.
eg. the evaluation order would be…
$Var1 && $Var2 => Result1
$Var3 && $Var4 => Result2
Result1 || Result2 => Final Result