“IF” argument evaluation order?

前端 未结 6 876
小鲜肉
小鲜肉 2020-12-02 18:17
if(a && b)
{
  do something;
}

is there any possibility to evaluate arguments from right to left(b -> a)?

if \"yes\", what influenc

6条回答
  •  一整个雨季
    2020-12-02 19:12

    In this case, since you're using &&, a will always be evaluated first because the result is used to determine whether or not to short-circuit the expression.

    If a returns false, then b is not allowed to evaluate at all.

提交回复
热议问题