“IF” argument evaluation order?

前端 未结 6 882
小鲜肉
小鲜肉 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:11

    It will evaluate from left to right and short-circuit the evaluation if it can (e.g. if a evaluates to false it won't evaluate b).

    If you care about the order they are evaluated in you just need to specify them in the desired order of evaluation in your if statement.

提交回复
热议问题